New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warn: client not handshaken client should reconnect #996

Closed
sapkal-manish opened this Issue Aug 17, 2012 · 21 comments

Comments

Projects
None yet
@sapkal-manish

sapkal-manish commented Aug 17, 2012

hello everyone..
i am new bee in socket.io and redis
i have developing one chat application. but i have facing one problem, and i don't understand how to solve it. i have read many articles/blogs, but still i have don't find any clue/solution for the same.

i have written following code:

server-side : (app.js)

var io = require('socket.io').listen(app);
io.configure(function () {
    io.set('log level', 3);
    io.set("transports", [ "jsonp-polling", "xhr-polling", "websocket", "flashsocket", "htmlfile" ]);
    io.set("polling duration", 10); 
    io.configure(function () {
        io.set('authorization', function (handshakeData, callback) {
            console.log(handshakeData);
            callback(null, true); // error first callback style 
        });
    });
});

client-side : (index.html)
<script src="http://XXX.XXX.X.XX/node_modules/socket.io-client/dist/socket.io.js" type="text/javascript"></script>

$(document).ready(function () {
chati = new Chat;
chati.Connect($("#nickname").val(), $("#room").val());
return false;
});

function Chat() {
this.socket = null;
this.Nickname = "";
this.Room = "";

    this.Connect = function (nick, room) {
        socket = io.connect('http://XXX.XXX.X.XX');

// socket = io.connect('http://XXX.XXX.X.XX', { 'reconnect': true, transports: ['jsonp-polling', 'xhr-polling'] });
// socket = io.connect('http://XXX.XXX.X.XX', { 'connect timeout': 500, 'reconnect': true, 'reconnection delay': 500, 'reopen delay': 500, 'max reconnection attempts': 10 });
Nickname = nick;
Room = room;

// setInterval(function () { socket.emit("keep-alive", null) }, 20 * 1000);

        socket.on('connect', function (data) {
            alert("connect");
            socket.emit('OnConnect', { nick: nick, room: room }, function (response) {
                $("#board").append("<p>" + response.msg + "</p>");
            });
        });

        socket.on("message", function (msg) {
            alert("message received on client ...");
            $("#board").append("<p>" + msg +"</p>");
        });

        server.on("listening", function () {
            var address = server.address();
            console.log("server listening " + address.address + ":" + address.port);
        });

    };

    this.Send = function Send(msg) {
        $("#board").append("<p> send message via client send() " + msg + " </p>");
        socket.emit("message", { msg: msg, nick: Nickname }, function (response) {
            $("#board").append("<p> send message : " + Nickname + ": " + msg + "</p>");
        });
    };
}

when i am running my application, there is continually fires request from client side. when i have check the error log, i have find some warning message

info: socket.io started
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect
warn: client not handshaken client should reconnect

so, let me know what is the mistake i have done in this code.

please help me.

@zhangjf108

This comment has been minimized.

zhangjf108 commented Sep 6, 2012

the same problem~

@jmyrland

This comment has been minimized.

jmyrland commented Sep 6, 2012

This is probably closely related to issue #438

@hhachim

This comment has been minimized.

hhachim commented Sep 25, 2012

hi all
is this problem resolved?

thx

@magickaito

This comment has been minimized.

magickaito commented Mar 19, 2013

i am facing this problem as well..

@hhachim

This comment has been minimized.

hhachim commented Mar 19, 2013

Helo magickaito,
in witch version are you facing this problem?
I'd like to know if the latest version is concerned.

Thx

@magickaito

This comment has been minimized.

magickaito commented Mar 19, 2013

hi, i am setting "socket.io":"0.9.x" in my dependencies settings for heroku deployment.

@lin04com

This comment has been minimized.

lin04com commented Apr 10, 2013

I get the same problem, any suggestion?

@purefan

This comment has been minimized.

purefan commented Apr 28, 2013

I am getting this problem when the server is running, clients are connected, I bring down the server, a few seconds pass and I start the server again, my guess is that it comes from the reconnect routine in the clients.

Raised the log error and this is what I got:

   debug - setting request GET /socket.io/1/xhr-polling/bRI9T0ap4UyCLzbC9pYz?t=1367144837853
   debug - setting poll timeout
   debug - clearing poll timeout
   debug - xhr-polling writing 5:::{"name":"authenticate"}
   debug - set close timeout for client bRI9T0ap4UyCLzbC9pYz
   debug - discarding transport
   debug - cleared close timeout for client bRI9T0ap4UyCLzbC9pYz
   debug - xhr-polling received data packet 0::
   debug - got disconnection packet
   info  - transport end by forced client disconnection
   info  - transport end (booted)
   debug - cleared close timeout for client bRI9T0ap4UyCLzbC9pYz

socket.io version is 0.9.14

@kurteknikk

This comment has been minimized.

kurteknikk commented May 24, 2013

I'm having the same issue... Do you need any particular information to figure out why this is going wrong ?

@roieki

This comment has been minimized.

roieki commented Jun 4, 2013

Experiencing the same issue. Any news?

@devpilot

This comment has been minimized.

devpilot commented Jun 5, 2013

Still getting lots of this warning message on my chat app

@xscconan

This comment has been minimized.

xscconan commented Jul 29, 2013

same issue with 0.9.16

@gagahjt

This comment has been minimized.

gagahjt commented Aug 2, 2013

The same problem with 0.9.16 (IE 7/8/9 Browser),Multi-process

@memeyou

This comment has been minimized.

memeyou commented Aug 16, 2013

I'm able to produce these errors by accepting connections over multiple threads behind a load-balancer without persisting the session data.

By giving all the nodes a common store the messages went away.

@jwarkentin

This comment has been minimized.

jwarkentin commented Aug 21, 2013

Hopefully this helps someone. I just did a little more investigating to try to figure out what's happening in my case and found some interesting stuff. I have several instances of my Socket.io app running behind a load balancer. Normally this is just fine, but sometimes something goes wrong and it falls back to long polling. When this happens the connections get bounced back and forth between the servers behind the load balancer. If it hits any server other than the one it originally authenticated with then it floods the logs with these errors. The simple solution is to use the RedisStore stuff to share session information between running instances. There are also other solutions. Here are some links that may be useful:

http://stackoverflow.com/questions/9617625/client-not-handshaken-client-should-reconnect-socket-io-in-cluster
http://stackoverflow.com/questions/9267292/examples-in-using-redisstore-in-socket-io
https://github.com/LearnBoost/Socket.IO/wiki/Configuring-Socket.IO (Look at the Redis Store config options)
https://github.com/fent/socket.io-clusterhub

@asethia

This comment has been minimized.

asethia commented Jan 1, 2014

Do we have any solution around this?? I am getting this error continuous.

@jwarkentin

This comment has been minimized.

jwarkentin commented Jan 1, 2014

Did you see my post right above yours? I've never personally seen the problem except when running multiple instances of my Socket.io server. Is that your situation? If so, look at my post above. I haven't had any problems since I started using the Redis store for sharing the handshake data. It's incredibly easy to implement.

@tylerbrownhenry

This comment has been minimized.

tylerbrownhenry commented Jan 2, 2014

jwarkentin's solution: https://github.com/fent/socket.io-clusterhub took about 30 seconds to get it working, seems to be doing the trick.

I was running into an issue where my page would load, and a connection wouldn't be made. So occasionally when this happened, and I emitted something to the server, I would get left in limbo.

This seems to have solved the problem.

Thanks for the help!

@asethia

This comment has been minimized.

asethia commented Jan 5, 2014

Thanks jwarentin. I added following lines, it is working

io.set('store', new RedisStore({
redisPub : redisPub
,redisSub : redisSub
,redisClient : redisclient
}));
io.set('log level', 1); // reduce logging
io.set('transports', [
'websocket'
, 'flashsocket'
, 'htmlfile'
, 'jsonp-polling'
]);

@tolgaytoklar

This comment has been minimized.

tolgaytoklar commented Jan 13, 2014

@asethia I have the same problem but I tested your code and I am getting RedisStore is not defined error.Can you help me ? tolgay007@gmail.com

@edgework

This comment has been minimized.

edgework commented Mar 30, 2014

RedisStore is a BAD solution. It leaks memory BIG TIME.

#1303

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment