socket.io
socket.io copied to clipboard
Socket server do not leave polling mode after connection is cut
You want to:
- [x] report a bug
- [ ] request a feature
Current behaviour
I recently detected a really strange behavior that is from what I observed a malfunction in socket.io server.
My socket is configured like this (configureSocketServer being the function where the socket.on etc are set):
const socketServer = io(httpServer, {
transports: ['polling', 'websocket'],
origins: [appConfig.appDomain],
});
socketServer.origins((origin, callback) => {
if (!origin.startsWith(appConfig.appDomain)) {
return callback('origin not allowed', false);
}
callback(null, true);
});
configureSocketServer(socketServer);
httpServer.listen(appConfig.port);
The scenario is the following : I have a socket.io server set in a docker behind an nginx docker with something like 1000 socket clients connected to it (client being android / iOS or browser implementations of socket.io). I If I restart the nginx docker, sockets become crazy:
- socket keep on polling and never upgrade to websocket
- server seems to be unable to free memory (see memory usage capture)
To provide some figures, today we add a little incident today around 13:00 that cut connections for like 5 seconds. At 14:00 we decided to restart socket.io server. From 13:40 to 13:50 we had 23910 socket request on nginx server with 23202 being polling (97%) From 14:20 to 14:40 we only have 1463 socket request and with 1202 being polling (80%)
What makes me think that the problem relies in the server :
- every client seems to go crazy whatever the implementation (js, java or swift)
- if I restart nginx at night (and not socket.io-server), socket polling occurs all night until the morning and when people start to connect, I need to restart my socket-io server.
- when I restart socket server everything goes back to normal
Other information (e.g. stacktraces, related issues, suggestions how to fix)