upload video with heroku server
See original GitHub issueim 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:
- upload video with
apollo-upload-client
- the resolver gets the video stream
- 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:
- Created 5 years ago
- Comments:6
@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.hi @mike-marcacci , i’ve resolve the multipart field order error. It was my fault, i didn’t use correctly the
Upload
component ofantd
. I was using thebeforeUpload
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.