Answer the question
In order to leave comments, you need to log in
Nodejs + Socket.io + https?
Created certificates via let's encrypt.
Got the files. Connected via nginx privkey.key fullchain.pem.
The domain has successfully started working on https and writes that it is protected.
But connecting the same certificates to the application. The client, when accepting them, rejects them with an error.
net::ERR_CONNECTION_CLOSED
Server-side code.
var fs = require('fs');
var options = {
key: fs.readFileSync('ssl/privkey.pem'),
cert: fs.readFileSync('ssl/fullchain.pem')
};
var httpServer = require('http').createServer();
var httpsServer = require('https').createServer(options);
var ioServer = require('socket.io');
var io = new ioServer();
io.attach(httpServer);
io.attach(httpsServer);
httpServer.listen(7165);
httpsServer.listen(7166);
io.sockets.on('connection', function (socket){});
var port = location.protocol === 'https:' ? 7166 : 7165;
var socketIO = io(0.0.0.0:'+port);
socketIO.once('connect', function(){});
Answer the question
In order to leave comments, you need to log in
But connecting the same certificates to the application. The client, when accepting them, rejects them with an error.
var socketIO = io('0.0.0.0:'+port);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question