Answer the question
In order to leave comments, you need to log in
Setting up a WebSocket connection over https?
Hello!
There is a client js:
let socket = io.connect('https://example.ru:3000');
var fs = require('fs');
let options = {
key: fs.readFileSync('/etc/letsencrypt/live/example.ru/privkey.pem'),
cert: fs.readFileSync('/etc/letsencrypt/live/example.ru/fullchain.pem'),
port: 3000,
};
let https = require('https').createServer(options);
let io = require('socket.io')(https);
let Redis = require('ioredis');
let redis = new Redis();
redis.psubscribe('channel_*');
redis.on('pmessage', function (pattern, channel, message) {
//console.log('Message recieved: ' + message);
//console.log('Channel: ' + channel);
msg = JSON.parse(message);
io.emit(channel, msg);
});
https.listen(3000, function () {
console.log('Listening on Port: 3000');
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question