我使用Node v0.12.18 和Express v4,对于一个POST请求,我收到此错误:
{ [Error: socket hang up] code: 'ECONNRESET' }
Error: socket hang up
at createHangUpError (_http_client.js:215:15)
at Socket.socketOnEnd (_http_client.js:300:23)
at Socket.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickDomainCallback (node.js:381:11)
使用此代码:
optionsYoutube = {
host: dostsub_host,
port: 80,
path: '/api/media/'+ uuid +'/youtube/push',
method: 'POST',
timeout: 1200000, //20 min
headers: {
'Authorization': auth
}
};
console.log('TRY > Youtube');
var postYoutube = http.request(optionsYoutube, function(json) {
json.on('data', function(d) {
body += d;
});
json.on('end', function() {
.....
}).on('error', function(err) {
console.log(err);
return next(err);
});
我尝试使用此API:https://dotsub.com/apidoc/api#youtube
我看起来可能是超时问题,所以我设置了我的app.js:
// set timeout
var timeout = require('connect-timeout');
app.use(timeout(1200000));
app.use(haltOnTimedout);
function haltOnTimedout(req, res, next){
if (!req.timedout) next();
}
但它没有改变。如何才能获得有关错误的更多信息?