Nodejs request Uncaught Error: write EPROTO when against port 443
Nodejs request Uncaught Error: write EPROTO when against port 443
我在尝试通过端口 443 上的 nodejs 请求模块使用我的 API 时收到错误 Uncaught Error: write EPROTO。如果我将端口更改为非 443 端口并请求到端口 443 上的应用程序通过浏览器和 curl 工作。
为什么我会得到 EPROTO 以及如何修复它以使我的自动化测试再次运行?
请求代码,它只是一个带有简单请求的 https 服务器:
var server = https.createServer ({secureProtocol: 'TLSv1_2_method',
key : fs.readFileSync('key'),
cert : fs.readFileSync('cert'),
ca: [
fs.readFileSync('othercert')
]
}, app);
还有一个简单的请求:
var request = require('request');
var basepath = "https://localhost";
var req_opts = {
method: "POST",
uri: basepath + '/myroute',
body: {
},
rejectUnauthorized: false,
json: true
}
request(req_opts, function(err, response, body){
if(err){
console.log(err);
throw(err);
}
console.log(body);
});
这只发生在我的本地 windows 机器上,而不发生在远程 ubuntu 服务器上。两者都有节点版本 4.2.3
搜索请求似乎无法协商密码,但如果不在端口 443 上,为什么会成功?
Skype 也在本地侦听端口 443,这就是发生这种情况的原因。
我在尝试通过端口 443 上的 nodejs 请求模块使用我的 API 时收到错误 Uncaught Error: write EPROTO。如果我将端口更改为非 443 端口并请求到端口 443 上的应用程序通过浏览器和 curl 工作。
为什么我会得到 EPROTO 以及如何修复它以使我的自动化测试再次运行?
请求代码,它只是一个带有简单请求的 https 服务器:
var server = https.createServer ({secureProtocol: 'TLSv1_2_method',
key : fs.readFileSync('key'),
cert : fs.readFileSync('cert'),
ca: [
fs.readFileSync('othercert')
]
}, app);
还有一个简单的请求:
var request = require('request');
var basepath = "https://localhost";
var req_opts = {
method: "POST",
uri: basepath + '/myroute',
body: {
},
rejectUnauthorized: false,
json: true
}
request(req_opts, function(err, response, body){
if(err){
console.log(err);
throw(err);
}
console.log(body);
});
这只发生在我的本地 windows 机器上,而不发生在远程 ubuntu 服务器上。两者都有节点版本 4.2.3
搜索请求似乎无法协商密码,但如果不在端口 443 上,为什么会成功?
Skype 也在本地侦听端口 443,这就是发生这种情况的原因。