i have this simple node.js Servercode using socket.io (1.5):
var io = require('socket.io').listen(8080);
io.on('connection', function(socket) {
console.log(' %s sockets connected', io.engine.clientsCount);
socket.on('disconnect', function() {
console.log("disconnect: ", socket.id);
});
});
If i run this code und press F5 several times, in some cases new connection is created, before the old one is disconnected. After some time, i think its the Heartbeat Timout, all the connections will be closed. See the result:
2 sockets connected
3 sockets connected
4 sockets connected
5 sockets connected
6 sockets connected
7 sockets connected
8 sockets connected
9 sockets connected
10 sockets connected
11 sockets connected
disconnect: 0h_9pkbAaE3ftKT9AAAL
11 sockets connected
12 sockets connected
13 sockets connected
14 sockets connected
disconnect: oB4HQRCOY1UIvvZkAAAP
14 sockets connected
15 sockets connected
disconnect: LiIN0oDVoqbePgxFAAAR
15 sockets connected
16 sockets connected
17 sockets connected
18 sockets connected
disconnect: zxvk-uhWABHzmu1uAAAV
18 sockets connected
19 sockets connected
20 sockets connected
disconnect: FlboxgTzcjf6ScffAAAY
20 sockets connected
21 sockets connected
disconnect: 9UGXbnzukfGX_UtWAAAa
21 sockets connected
disconnect: pAfXOEz6RocKZdoZAAAb
21 sockets connected
disconnect: DIhTyVgG2LYBawaiAAAc
21 sockets connected
disconnect: W4XOc1iRymfTE2U0AAAd
21 sockets connected
disconnect: WZzegGPcoGDNLRTGAAAe
21 sockets connected
22 sockets connected
disconnect: KVR3-fYH0cz77BmgAAAC
disconnect: ANQknhnxr4l-OAuIAAAD
disconnect: KZE5orNx6u9MbOArAAAE
disconnect: TS6LL3asXrcznfcPAAAF
disconnect: SVNxS3I7KqecdqKhAAAG
disconnect: IE2WE5Y0PJzvxgBfAAAH
disconnect: v69bdJav9PjpThBGAAAI
disconnect: mJKT1ggfOOTshZKgAAAJ
disconnect: YlycVjdcWe0emCAcAAAK
disconnect: MoIDJSzP_L-1RUwuAAAM
disconnect: wAl0x5qwCkrnDDYQAAAN
disconnect: eiTlPEk2Hx_X-L-fAAAO
disconnect: KgkrXxzG_EpXOsPTAAAQ
disconnect: Lvf3kK-6XXEbu3NWAAAS
disconnect: -hOoGdYOIvVK04K_AAAT
disconnect: 3EUmaAYpK-U3Ss9tAAAU
disconnect: HQ6M98FebtKlU3OfAAAW
disconnect: OwgrbRBYbS4j84nmAAAX
disconnect: yN8FZAP4RjUNl2MeAAAZ
disconnect: K9IFTjlgAWzdNfpUAAAf
My Question is: Is this a Bug or is this the normal behavior of socket.io? How can i prevent the connection flooding, simple pressing F5?
Best Regards Marc
See Question&Answers more detail:os