Answer the question
In order to leave comments, you need to log in
How to connect a certificate to socket io?
Hello dear users. I have a question, how to connect ssl certificates with socket io?
Here's the torn code - this is how the server is configured:
var io = require('socket.io').listen(2095);
var http = require('http');
This is how clients connect:
var socketIO = io(':2095',{'max reconnection attempts':Infinity});
But... When I go through http, everything works for me, but when I write https, it doesn't work, but in the console it says that it can't connect by clicking on the socket request link ( https://domain.pw:2095/socket .io/?EIO=3&transport=... ) gives me something saying "An error occurred while establishing a secure connection". But how to make it secure?
I don't understand any of this!
Answer the question
In order to leave comments, you need to log in
var https = require('https');
var fs = require('fs');
var port = 3001;
var options = {
key: fs.readFileSync('www_site_com.key').toString(),
cert: fs.readFileSync('www_site_com.crt').toString(),
ca: fs.readFileSync('www_site_com.ca-bundle').toString()
};
var app = https.createServer(options);
var io = require('socket.io').listen(app); //socket.io server listens to https connections
app.listen(port, "0.0.0.0", function() {
console.log('Listening on Port:' + port);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question