我运行node myserver.js
包含代码波纹管,并在40-50sec后我得到错误(在代码下面)。什么都没有发生时为什么会出现错误?NodeJs错误:连接ETIMEDOUT
var options = {
host: 'google.com',
port: '80',
path: '/',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': 'post_data.length'
}
};
var subscribeRequest = require('http').request(options, function(res) {
console.log('send request');
}).on('error', function(err){console.log(err.stack)});
Error: connect ETIMEDOUT
at errnoException (net.js:904:11)
at Object.afterConnect [as oncomplete] (net.js:895:19)
这也发生在服务器拒绝你的请求时。如果你请求服务器的许多请求,他们可能会阻止你一段时间后,会导致此错误。 –