【发布时间】:2020-06-17 20:10:45
【问题描述】:
我一直在尝试通过http节点模块通过以下代码发送http请求
const https = require('https')
http.request('http://newportal.timesgroup.cn/Pages/Home.aspx', () => {
console.log('success')
})
但收到消息
events.js:174
投掷者; // 未处理的“错误”事件
^
错误:套接字挂断
在 createHangUpError (_http_client.js:332:15) 时
在 TLSSocket.socketOnEnd (_http_client.js:435:23)
在 TLSSocket.emit (events.js:203:15)
在 endReadableNT (_stream_readable.js:1145:12)
在 process._tickCallback (internal/process/next_tick.js:63:19)
在以下位置发出“错误”事件:
在 TLSSocket.socketOnEnd (_http_client.js:435:9)
在 TLSSocket.emit (events.js:203:15)
在 endReadableNT (_stream_readable.js:1145:12)
在 process._tickCallback (internal/process/next_tick.js:63:19)
当我将代码切换到
const request = require('request')
request.get('http://newportal.timesgroup.cn/Pages/Home.aspx', () => {
console.log('success')
})
它成功了,得到了 200 个响应。
然后我尝试用Fiddler抓取网络包,发现使用http.request时没有发送包。
此错误仅发生在我们工作域网络内的 Windows 系统中。
【问题讨论】:
标签: node.js windows http firewall