question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

upload video with heroku server

See original GitHub issue

im trying to upload video using a heroku server, but i got H18 error https://devcenter.heroku.com/articles/error-codes#h18-server-request-interrupted

im using this flow:

  1. upload video with apollo-upload-client
  2. the resolver gets the video stream
  3. then i use youtube-api npm package to upload video to youtube

all worked fine on my local machine, but once i deployed it to heroku server i got error H18 during uploading.

error:

client log:

Network error: Failed to fetch POST https://staging-www.italianfishingtv.it/graphql net::ERR_CONNECTION_RESET

server log

2018-11-07T12:31:53.985268+00:00 heroku[router]: sock=backend at=error code=H18 desc="Server Request Interrupted" method=POST path="/graphql" host=staging-www.italianfishingtv.it request_id=d64d92f2-4518-4c15-83ce-42531998a16b fwd="87.20.112.78" dyno=web.1 connect=0ms service=469ms status=503 bytes=340 protocol=https

client config:

const authLink = new ApolloLink((operation, forward) => {
    const token = Accounts._storedLoginToken();

    operation.setContext(() => ({
        headers: {
            'meteor-login-token': token
        }
    }));

    return forward(operation);
});

const uploadLink = createUploadLink({
    uri: Meteor.absoluteUrl('graphql')
});

const cache = new InMemoryCache();

const apolloClient = new ApolloClient({
    cache,
    link: authLink.concat(uploadLink)
    // link: uploadLink
});

server config:

createApolloServer(
        {schema},
        {
            graphiql: true,
            configServer: expressServer => {
                expressServer.use(bodyParser.json({limit: '1000mb'}));
                expressServer.use(graphqlUploadExpress());
            }
        }
    );

resolver:

export const resolvers = {
    Mutation: {
        async submitFishWithFather(obj, {data}, {user}) {
            const {stream, filename, mimetype, encoding} = await data.upload;

            const req = Youtube.videos.insert({
                resource: {
                    // Video title and description
                    snippet: {
                        title: `a pesca con papà - ${data.name} ${data.surname} - ${data.email} - ${new Date()}`,
                    },
                    status: {
                        privacyStatus: "private"
                    }
                },
                part: "snippet,status",
                media: {
                    body: stream
                }
            }, (err, videoData) => {
                if (err) {
                    throw  err;
                }
                console.log(videoData);

                sendNotificationEmail(data, videoData);
            });


            return {};
        }
    }
};

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
nenejicommented, Nov 9, 2018

@mike-marcacci , i’ve resolved the problem. The issue is generated by an auth problem with youtube-api package. Now i’m using the google’s official package and it’s all ok now.

0reactions
nenejicommented, Nov 9, 2018

hi @mike-marcacci , i’ve resolve the multipart field order error. It was my fault, i didn’t use correctly the Upload component of antd. I was using the beforeUpload handler to get the file info and it should return false to prevent the build-in upload event.

And now a fresh deployed application doesn’t give me any error, but if i try to upload a new video after few hours BOOM, h18.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Simple File Upload | Heroku Dev Center
Simple File Upload is an add-on for providing direct image and file uploading to the cloud.
Read more >
Upload Files with Simple File Upload - YouTube
Your browser can't play this video. ... hard 0:50 - Adding Simple File Upload on Heroku 1:15 - Add the uploader to a...
Read more >
How To Deploy to Heroku in 5 Minutes - YouTube
In this video I teach how to deploy an api to Heroku in under 5 ... Heroku is one of the best services...
Read more >
How to upload project on Heroku in 5 minutes - YouTube
How to upload project on Heroku in 5 minutes | Deploy your App on HerokuIn this video I am going to show you...
Read more >
Upload NodeJS App to Heroku in 10 mins - YouTube
In this Tutorial, I'm going to explain how to deploy your NodeJS app on Heroku. Heroku - https://www. heroku.comNodeJS- https://nodejs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found