Answer the question
In order to leave comments, you need to log in
Why does socket.io call connect callback multiple times after page reload?
Customer:
var token = getCookie("token");
var socket = io('http://localhost:3000/', {
query: "&token=" + token
});
socket.on('connect', function() {
console.log('Connected to server.');
});
io.on('connection', function (socket) {
var token = socket.handshake.query.token;
console.log("[Socket.IO] New user connected! Token: " + token + " Socket ID: " + socket.id);
socket.on('disconnect', function() {
console.log('[Socket.IO] User disconnected! Token:" + token + " Socket ID: ' + socket.id);
});
});
Answer the question
In order to leave comments, you need to log in
I don’t know yet what it was connected with, but after a lot of different manipulations with the code, the problem was solved. Now everything seems to be returned as it was and still I don’t observe this problem anymore.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question