小编JSB*_*ach的帖子

Node.js v8.11.1 尝试使用 https 模块 POST 时出现 EPROTO 错误

我有一个在 AWS 上的 Node 8.11.1 上运行的系统。有一个功能可以将日志写入另一台服务器。该函数接受它记录的请求对象。

我的问题是在实际的 POST 尝试期间出现的,出现以下错误:

错误:写入 EPROTO 139746875082624:错误:140770FC:SSL 例程:SSL23_GET_SERVER_HELLO:未知协议:../deps/openssl/openssl/ssl/s23_clnt.c:827:

我看不出我的代码有什么问题。
为什么会出现错误?我可以采取什么措施来修复它?

这是函数内部的代码:

const https = require('https');    
try
{
   const postData = "New log finished " + JSON.stringify(request, null, 2);

   const options =
   {
      hostname: LOG_DOMAIN,
      port: LOG_PORT,
      path: '/',
      method: 'POST'
   };

   const req = https.request(options);
   req.on('error', (e) =>
   {
      console.error("ERROR writing logs: " + e);
   });
   req.write(postData);
   req.end();
}
catch (e)
{
   console.log(e);
}
Run Code Online (Sandbox Code Playgroud)

LOG_DOMAIN 和 LOG_PORT 是传递给函数的变量。

https post node.js

6
推荐指数
1
解决办法
9805
查看次数

标签 统计

https ×1

node.js ×1

post ×1