socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

Socket.io + SSL cert problem

Open cr4md3v opened this issue 12 years ago • 5 comments

Hello I implemented this on my server.js: var express = require('express'), http = require('http'), https = require("https"), server = http.createServer(app), fs = require('fs');

var app = express();

//SSL Keys var privateKey = fs.readFileSync('sslcert/server.key'); var certificate = fs.readFileSync('sslcert/server.crt');

//Apply the SSL var credentials = {key: privateKey, cert: certificate}; var httpsServer = https.createServer(credentials, app);

//Start the connection //httpsServer.listen(8080, 'localhost'); httpsServer.listen(8080); console.log("Listening.....");

//Start Scoket.io var io = require("socket.io").listen(httpsServer, credentials);

When I visit my app I see:

ReferenceError: io is not defined var socket = io.connect('https://mydomain.com:8080');

Then, if I visit https://mydomain.com:8080/socket.io/socket.io.js I see NOT trusted connection and the tipical button to add an exception. My question is: is a problem with .key and .crt files? Is a problem of socket.io configuration?

Help please!!

cr4md3v avatar Nov 26 '14 19:11 cr4md3v

Are you adding the socket.io client script in your page?

yads avatar Nov 26 '14 23:11 yads

Yes I loading it via

cr4md3v avatar Nov 26 '14 23:11 cr4md3v

You can better use nginx or haproxy to do the ssl part. Configure them as a load balancer on top of all your nodejs web stuff actually.

marcofranssen avatar Nov 27 '14 08:11 marcofranssen

Do you still have the problem?

nkzawa avatar Dec 25 '14 17:12 nkzawa

That issue was closed automatically. Please check if your issue is fixed with the latest release, and reopen if needed (with a fiddle reproducing the issue if possible).

darrachequesne avatar Jan 12 '17 15:01 darrachequesne