简体   繁体   中英

Socket.IO SSL connection error not using express

I'm trying to connect to my Socket.IO server, but the connection couldn't be made. It works without HTTPS. I created the pem and crt file with openssl command, I also have opened port 3300 through Firewall.

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');

Calling the server/url.

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

NodeJS is just as a backend, I'm not using express or anything on there.

Try using,

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

UPDATE

Try following the instructions in

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM