【问题标题】:Socket.IO SSL connection error not using expressSocket.IO SSL 连接错误未使用 express
【发布时间】:2017-04-20 18:39:28
【问题描述】:

我正在尝试连接到我的 Socket.IO 服务器,但无法建立连接。它可以在没有 HTTPS 的情况下工作。我用openssl命令创建了pem和crt文件,我还通过防火墙打开了端口3300

var https = require('https');
var options = {
  key: fs.readFileSync('file.pem'),
  cert: fs.readFileSync('file.crt')
};
var app = https.createServer(options);
io.listen(app); 
app.listen('3300');

调用服务器/url。

io('https://example.com:3300');

NodeJS 只是作为后端,我没有使用 express 或其他任何东西。

【问题讨论】:

  • 客户端/浏览器记录了什么?

标签: javascript node.js socket.io


【解决方案1】:

尝试使用,

var socket = io.connect('https://localhost:3300', {secure: true})

更新

尝试按照

中的说明进行操作

How to use HTTPS on Node.js using Express/Socket.io

【讨论】:

  • 您尝试更新了吗?
猜你喜欢
  • 2016-09-09
  • 1970-01-01
  • 1970-01-01
  • 2015-01-02
  • 2014-06-26
  • 2017-03-14
  • 1970-01-01
  • 2017-01-08
  • 2012-11-18
相关资源
最近更新 更多