Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot connect to secure socket.io server : ERR_SSL_PROTOCOL_ERROR

I'm trying to use socket.io with existing application. My application runs on https://somedomain.com. Its using this code to connect to socket io server:

 var socket = io('https://localhost:3456/');
  socket.on('connect', function () {
    socket.send('hi');

    socket.on('message', function (msg) {
      // my msg
    });
  });

My socket.io server has this code to listen to incoming connections:

var io = require('socket.io').listen(3456);

io.sockets.on('connection', function(socket) {
    console.log("dupa");
    socket.on('message', function() {});
    socket.on('disconnect', function() {});
});

dupa is never displayed on server side and in Chrome browser console I receive:

GET https://localhost:3456/socket.io/?EIO=3&transport=polling&t=1412901063154-0 net::ERR_SSL_PROTOCOL_ERROR 

How can I get this possibly working?

like image 386
spirytus Avatar asked Oct 10 '14 00:10

spirytus


People also ask

Does Socket.IO work on https?

If you want socket.io to use https, just pass a key param to the listen() function. You can also run your server behind stunnel. You received this message because you are subscribed to the Google Groups "Socket.IO" group.


1 Answers

Change https to http

var socket = io.connect("http://localhost:4000");

like image 165
testing_22 Avatar answered Sep 21 '22 17:09

testing_22