title: How to avoid warning "client not handshaken client should reconnect" in socket.io?
body: <p>I have nodejs application in my project on php. The main aim of it is to send messages about new events to client.</p>
  
  <p>I use for it socket.io and redis pub/sub. I have one redis channel. For example when user send email to other user on a site php code publish this message to redis channel. Nodejs app subscribes to this redis channel and send new message to client. On server I have 16 core cpu, 2.4GHz, 16GB RAM and nodejs v0.10.18. Avg cpu using is 9%. Avg connections to nodejs are 1500. And in my node log I very often can find warning:</p>
  
  <blockquote>
    <p>warn  - client not handshaken client should reconnect</p>
  </blockquote>
  
  <p>After this warning clients disconnected and didn't get new messages.
  What can be reason of it?</p>
  
  <p>I make test nodejs app and you can see it on github
  <a href="https://github.com/devdemi/notifier-cluster" rel="nofollow">https://github.com/devdemi/notifier-cluster</a>
  I tried to open 4 browser window and logged with 2 different users.
  I publish to redis channel 7 messages and each socket receive this 7 messages. So I have 4 sockets then nodejs get 21 messages. I think it's bad but I have no idea how to write code better. Please advice.</p>
  
  <pre><code>&gt; Chanel[notifier-message]:21kxiNqfupovXAgnpH7o: get message 101==101
  &gt; Sent message [notifier-message]:21kxiNqfupovXAgnpH7o:
  &gt; {"toUserId":101,"message":1390053553752}
  &gt; Chanel[notifier-message]:R5hDp02fq3yeX4vupH7p: get message 104==101
  &gt; Chanel[notifier-message]:jQllRPNT1TIRn8YhpH7q: get message 101==101
  &gt; Sent message [notifier-message]:jQllRPNT1TIRn8YhpH7q:
  &gt; {"toUserId":101,"message":1390053553752}
  &gt; Chanel[notifier-message]:XTHshkPmN-uTzP6tpH7n: get message 104==101
  &gt; Chanel[notifier-message]:21kxiNqfupovXAgnpH7o: get message 101==102
  &gt; Chanel[notifier-message]:R5hDp02fq3yeX4vupH7p: get message 104==102
  &gt; Chanel[notifier-message]:jQllRPNT1TIRn8YhpH7q: get message 101==102
  &gt; Chanel[notifier-message]:XTHshkPmN-uTzP6tpH7n: get message 104==102
  &gt; Chanel[notifier-message]:21kxiNqfupovXAgnpH7o: get message 101==103
  &gt; Chanel[notifier-message]:R5hDp02fq3yeX4vupH7p: get message 104==103
  &gt; Chanel[notifier-message]:jQllRPNT1TIRn8YhpH7q: get message 101==103
  &gt; Chanel[notifier-message]:XTHshkPmN-uTzP6tpH7n: get message 104==103
  &gt; Chanel[notifier-message]:21kxiNqfupovXAgnpH7o: get message 101==104
  &gt; Chanel[notifier-message]:R5hDp02fq3yeX4vupH7p: get message 104==104
  &gt; Sent message [notifier-message]:R5hDp02fq3yeX4vupH7p:
  &gt; {"toUserId":104,"message":1390053553752}
  &gt; Chanel[notifier-message]:jQllRPNT1TIRn8YhpH7q: get message 101==104
  &gt; Chanel[notifier-message]:XTHshkPmN-uTzP6tpH7n: get message 104==104
  &gt; Sent message [notifier-message]:XTHshkPmN-uTzP6tpH7n:
  &gt; {"toUserId":104,"message":1390053553752}
  &gt; Chanel[notifier-message]:21kxiNqfupovXAgnpH7o: get message 101==105
  &gt; Chanel[notifier-message]:R5hDp02fq3yeX4vupH7p: get message 104==105
  &gt; Chanel[notifier-message]:jQllRPNT1TIRn8YhpH7q: get message 101==105
  &gt; Chanel[notifier-message]:XTHshkPmN-uTzP6tpH7n: get message 104==105
  &gt; Chanel[notifier-message]:21kxiNqfupovXAgnpH7o: get message 101==106
  &gt; Chanel[notifier-message]:R5hDp02fq3yeX4vupH7p: get message 104==106
  &gt; Chanel[notifier-message]:jQllRPNT1TIRn8YhpH7q: get message 101==106
  &gt; Chanel[notifier-message]:XTHshkPmN-uTzP6tpH7n: get message 104==106
  &gt; Chanel[notifier-message]:21kxiNqfupovXAgnpH7o: get message 101==107
  &gt; Chanel[notifier-message]:R5hDp02fq3yeX4vupH7p: get message 104==107
  &gt; Chanel[notifier-message]:jQllRPNT1TIRn8YhpH7q: get message 101==107
  &gt; Chanel[notifier-message]:XTHshkPmN-uTzP6tpH7n: get message 104==107
  </code></pre>
  
  <p>I read that to avoid warning "client not handshaken client should reconnect" I need to use clusters.
  I have next logs after sending 7 messages to redis channel:</p>
  
  <pre><code>&gt; Chanel[notifier-message]:LFthahgJCELKAco3sY64:6564:get message
  &gt; 101==101 Sent message [notifier-message]:LFthahgJCELKAco3sY64:
  &gt; {"toUserId":101,"message":1390054397147}
  &gt; Chanel[notifier-message]:xyZU162eAZQBz0YEsY65:6565:get message
  &gt; 101==101 Sent message [notifier-message]:xyZU162eAZQBz0YEsY65:
  &gt; {"toUserId":101,"message":1390054397147}
  &gt; Chanel[notifier-message]:OU5RrgvoyDyuu7lOsY63:6564:get message
  &gt; 102==101 Chanel[notifier-message]:G4J0aXzhRRLWxidOsY66:6564:get
  &gt; message 102==101
  &gt; Chanel[notifier-message]:LFthahgJCELKAco3sY64:6564:get message
  &gt; 101==102 Chanel[notifier-message]:OU5RrgvoyDyuu7lOsY63:6564:get
  &gt; message 102==102
  &gt; Chanel[notifier-message]:xyZU162eAZQBz0YEsY65:6565:get message
  &gt; 101==102 Sent message [notifier-message]:OU5RrgvoyDyuu7lOsY63:
  &gt; {"toUserId":102,"message":1390054397148}
  &gt; Chanel[notifier-message]:xyZU162eAZQBz0YEsY65:6565:get message
  &gt; 101==103 Chanel[notifier-message]:xyZU162eAZQBz0YEsY65:6565:get
  &gt; message 101==104
  &gt; Chanel[notifier-message]:G4J0aXzhRRLWxidOsY66:6564:get message
  &gt; 102==102 Chanel[notifier-message]:xyZU162eAZQBz0YEsY65:6565:get
  &gt; message 101==105 Sent message [notifier-message]:G4J0aXzhRRLWxidOsY66:
  &gt; {"toUserId":102,"message":1390054397148}
  &gt; Chanel[notifier-message]:xyZU162eAZQBz0YEsY65:6565:get message
  &gt; 101==106 Chanel[notifier-message]:xyZU162eAZQBz0YEsY65:6565:get
  &gt; message 101==107
  &gt; Chanel[notifier-message]:LFthahgJCELKAco3sY64:6564:get message
  &gt; 101==103 Chanel[notifier-message]:OU5RrgvoyDyuu7lOsY63:6564:get
  &gt; message 102==103
  &gt; Chanel[notifier-message]:G4J0aXzhRRLWxidOsY66:6564:get message
  &gt; 102==103 Chanel[notifier-message]:LFthahgJCELKAco3sY64:6564:get
  &gt; message 101==104
  &gt; Chanel[notifier-message]:OU5RrgvoyDyuu7lOsY63:6564:get message
  &gt; 102==104 Chanel[notifier-message]:G4J0aXzhRRLWxidOsY66:6564:get
  &gt; message 102==104
  &gt; Chanel[notifier-message]:LFthahgJCELKAco3sY64:6564:get message
  &gt; 101==105 Chanel[notifier-message]:OU5RrgvoyDyuu7lOsY63:6564:get
  &gt; message 102==105
  &gt; Chanel[notifier-message]:G4J0aXzhRRLWxidOsY66:6564:get message
  &gt; 102==105 Chanel[notifier-message]:LFthahgJCELKAco3sY64:6564:get
  &gt; message 101==106
  &gt; Chanel[notifier-message]:OU5RrgvoyDyuu7lOsY63:6564:get message
  &gt; 102==106 Chanel[notifier-message]:G4J0aXzhRRLWxidOsY66:6564:get
  &gt; message 102==106
  &gt; Chanel[notifier-message]:LFthahgJCELKAco3sY64:6564:get message
  &gt; 101==107 Chanel[notifier-message]:OU5RrgvoyDyuu7lOsY63:6564:get
  &gt; message 102==107
  &gt; Chanel[notifier-message]:G4J0aXzhRRLWxidOsY66:6564:get message
  &gt; 102==107
  </code></pre>
  
  <p>I started it on my laptop with intel core i5 cpu with 4 cores. When I use 2 core its works fine. But I use 4 core I get messages:</p>
  
  <blockquote>
    <p>warn  - client not handshaken client should reconnect</p>
  </blockquote>
  
  <p>Please explain how clusters works exactly? And What do I need to avoid this warnings?</p>