Answer the question
In order to leave comments, you need to log in
How to send a socket message over https?
Hello, I have a domain and vps that hosts the site.
The domain is directed to the cloudflare servers, and there it is connected to the VPS IP.
When using Cloudflare, the site can work over https.
The site has a real-time online counter, data is transmitted via socket.io.
And everything works fine via http, but if you go via https, then the site tries to get data via https, which is not configured on the server and it is not needed there! That is, https online is not displayed
Please tell me how to solve this problem.
Answer the question
In order to leave comments, you need to log in
Raise via https.
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);
});
Wow, use ByteBuffer from Java NIO, it will be nice! There are just the right methods like getInt / Float, etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question