var requestOptions={ host:’117.25.150.78’, port:8080, path:’/url’, method:’GET’ } http.request(requestOptions,function (res){ res.on('data’,function (data){ console.log(data.toString()) }); }); 报错: events.js:72 throw er; // Unhandled ‘error’ event ^ Error: socket hang up at createHangUpError (http.js:1472:15) at Socket.socketOnEnd [as onend] (http.js:1568:23) at Socket.g (events.js:180:16) at Socket.EventEmitter.emit (events.js:117:20) at _stream_readable.js:919:16 at process._tickCallback (node.js:419:13)
6 回复
@yunfei 请求没有发出去, 一直 socket hang up.
js
var req = http.request(requestOptions,function (res){
res.on('data’,function (data){
console.log(data.toString())
});
});
req.end(); // 发送请求