Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

client not handshaken client should reconnect, socket.io in cluster

client not handshaken client should reconnect, socket.io in cluster

Problem

My node.js app with express, redis, mongo and socket.io works prefectly. Today when I introduced cluster, I found that it works, but there are lot of messages by the app,

'client not handshaken' 'client should reconnect'

Many a times the response time from socket.io is very bad, up several seconds.

Then I used http-proxy front ending the requests from the browsers. Chrome works intermittently without throwing up such messages. Sometimes if I open the same URL again, it starts throwing up these messages and response is delayed. Firefox also behaves the same way. randomly, it starts throwing these messages continuously.. Looks like some problem with websocket in clustered environment.

My node.js version is 0.6.10, socket.io 0.9.0, express 2.5.9, http-proxy 0.8.0

Problem courtesy of: user644745

Solution

This is most probably because Socket.IO keeps your connections in memory, so each server will have it's own set of clients. To share Socket.IO over multiple server instances, look into using their RedisStore. The same applies to Express sessions, where you have connect-redis as an option.

Solution courtesy of: Linus Gustav Larsson Thiel

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

client not handshaken client should reconnect, socket.io in cluster

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×