Reputation: 15
I've read through nearly every possible tutorial about how to receive SSL through socket.io and I just can't seem to get it to work.
My backend JS is as follows:
var express = require('express');
var options = {
key: fs.readFileSync('/key.key'),
cert: fs.readFileSync('/crt.crt'),
requestCert: true
};
var app = express();
var server = require('https').createServer(options, app);
var io = require('socket.io').listen(server);
server.listen(2096, "IP Address");
The frontend JS:
SOCKET = io('https://name.com:443', {secure: true});
I'm using full SSL, with cloudflare signed certificates install on my server.
I also receive the following error when connecting:
POST https://name.com/socket.io/?EIO=3&transport=polling&t=LcBk2Vk 404()
I'm not sure if my ports are incorrect or I'm missing something entirely.
I'm happy to provide more code snippets.
Thanks in advance
Upvotes: 1
Views: 2036
Reputation: 4399
You are simply listening on the wrong port. SSL traffic is served over 443 usually, in order to fix this you should substitute:
server.listen(2096, "IP Address");
With something like this:
server.listen(443);
Upvotes: 1