Connection closed before receiving acknowledgment confirmation signal - Socket.io

I use socket.io and everything works, I believe somewhat correctly:

2015-16:8 Starting... //console of site
socket.io-1.3.5.js:3 WebSocket connection to 'ws://localhost:4000/socket.io/?EIO=3&transport=websocket&sid=whN8kQi1bFtqzaCAAAAH' failed: Connection closed before receiving a handshake response

Frontend

script(src="https://cdn.socket.io/socket.io-1.3.5.js")
script.
    $(document).ready(function () {
        var socket = io();
        socket.on('admin', function (data) {
            console.info(data);
        });
    })

node

var io = require('socket.io').listen(server);
io.on('connection', function (socket) {
    socket.emit('admin', 'Starting...');
    socket.on('admin', function (from, msg) {
      console.log('I received a private message by ', from, ' saying ', msg);
    });
});

Inside Node Controller

 app.io.sockets.emit('admin', 'Starting Scrape');

I do not call socket.io twice, and I believe that it works correctly. How can I stop this error.

+4
source share

Source: https://habr.com/ru/post/1606668/


All Articles