我的问题是,每当我尝试通过HTTPS连接到Websocket服务器时,都会引发连接错误。
我已经通过HTTP进行了尝试,效果很好。
server.js
var fs = require('fs')
var options = {
key: fs.readFileSync('/etc/letsencrypt/live/roast-tv.se/privkey.pem'),
cert: fs.readFileSync('/etc/letsencrypt/live/roast-tv.se/fullchain.pem')
};
var app = require('https').createServer(options);
var io = require("socket.io").listen(app);
app.listen(3000);
client.js
var socket = io.connect('https://roast-tv.se:3000', {secure: true});
它在Google检查工具控制台中抛出此错误。
错误:
GET https://roast-tv.se:3000/socket.io/?EIO=3&transport=polling&t=Ms7JP5S
net::ERR_CONNECTION_TIMED_OUT