-
Notifications
You must be signed in to change notification settings - Fork 6
Enough socket.io-event routers attached to socket causes a crash when enough clients does reconnect. #19
Copy link
Copy link
Open
Description
When 20 or more routers are attached to socket using socket.use reconnection attempt causes unhandled errors when enough clients does reconnection simultaenously. Error doesn't appear if I attach vanilla handlers (without socket.io-events router) to socket with socket.use.
Error message:
TypeError: Uncaught, unspecified "error" event.
at TypeError (<anonymous>)
at Socket.EventEmitter.emit (events.js:74:15)
at next (/home/jtiai/Code/websockets/node_modules/socket.io-events/lib/router.js:130:20)
at step (/home/jtiai/Code/websockets/node_modules/socket.io-events/lib/router.js:188:9)
at next (/home/jtiai/Code/websockets/node_modules/socket.io-events/lib/router.js:144:11)
at next (/home/jtiai/Code/websockets/node_modules/socket.io-events/lib/router.js:136:15)
at step (/home/jtiai/Code/websockets/node_modules/socket.io-events/lib/router.js:149:23)
at Router.router.onRoute (/home/jtiai/Code/websockets/node_modules/socket.io-events/lib/router.js:191:7)
at step (/home/jtiai/Code/websockets/node_modules/socket.io-events/lib/router.js:176:18)
at next (/home/jtiai/Code/websockets/node_modules/socket.io-events/lib/router.js:144:11)
Number of required clients seem to vary but in my environments I get consistent results with 20 routers and 100 concurrent clients.
Steps to reproduce:
- start server.py with
nodejs server.py - start client.py with
nodejs client.py - Observe successful connections
- stop server.py
- start server.py again
- Observe errors when clients do reconnect.
server.py:
const PORT = 3000;
var sock = require('socket.io')(PORT);
sock.on('connect', function() {
console.log('Successful connection');
});
sock.on('disconnect', function() {
console.log('Disconnected');
});
// Create 20 individual routers and attach them to socket
for (var i=0;i < 20;i++) {
(function (id) {
var router = require('socket.io-events')();
router.on('msg'+id, function(sock, next) {});
sock.use(router);
})(i);
}
client.py:
const PORT = 3000;
var Client = require('socket.io-client');
// Connect 100 clients
for (var i=0; i < 100; i++) {
(function(id) {
var sock = Client('http://localhost:'+PORT, { multiplex: false });
sock.on('connect', function() {
console.log('Connection %s connected', id);
})
sock.on('disconnect', function() {
console.log('Connection %s disconnected', id);
})
sock.on('reconnect', function() {
sock.emit('relogin', 'user-' + id);
console.log('Connection %s reconnected', id);
})
})(i);
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels