socket.io-redis-adapter: timeout reached while waiting for clients response
I’m getting a lot of errors when calling
io.of("/").adapter.clients([roomId], function (err, clientSockets) {
error:
timeout reached while waiting for clients response
Is this a result of roomId not existing or should I be checking some other thing?
Thanks!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 20
- Comments: 53 (6 by maintainers)
Commits related to this issue
- chore(deps): Upgrade socket.io-redis dependency for fix related to recent downtime https://github.com/socketio/socket.io-redis/issues/210 — committed to outline/outline by tommoor 4 years ago
I have been investigating the error “Timeout reached …” and as mentioned by @darrachequesne it seems to come from an error with numsub (issue #267).
During my tests on the function “allRooms” to get the list of all rooms across every node, I noticed 3 types of response :
I used the following configuration:
By monitoring the 3 redis I noted the following subscriptions :
As mentioned in the issue #267 by @SunGg12138, “pubsub numsub channel” it returns only the results pertaining to the server you’re directly connected to.
So in my case: When “pubsub numsub channel” is received by the redis-1 it systematically returns the “Timeout error”. When “pubsub numsub channel” is received by the redis-2 it only returns the rooms of one of the three nodes ( it is not always the same node). When “pubsub numsub channel” is received by the redis-3 it returns the rooms of two of the three nodes ( it is not always the same nodes).
This could explain the error of the empty array ( only the nodes without rooms are requested). As the response with the array with all the rooms ( the nodes with no rooms are not requested which does not affect the expected result).
I then restarted the clients to have another configuration:
In this configuration I had only two types of response:
I restarted the clients again to have another configuration:
In this configuration I had only two types of response:
Those results seems to confirm that the problem comes from numsub.
Finally, I manually set the value of numsub to 3 (in the source code) which corresponds to the number of clients. And I only had the good responses : An array with all the rooms across the nodes.
I imagine that solving the issue #267 will solve this one too.
I have the same issue as well.
Have the same issue, retry_strategy and requestsTimeout == 3000 doesn’t help
The current behaviour for
clientsmethod:socket.io-request#/#channel withnumsubsocket.io-request#/#channelsocket.io-response#/#channelWhat could cause
timeout reached while waiting for clients response:numsubis incorrect (which is what happen with a Redis cluster, https://github.com/socketio/socket.io-redis/issues/267)I’m open to suggestions for how to fix that issue.
When i try to join a client in different name space to a room is in another name-space like this:
It will do ‘PUBLISH’ command in redis when i do monitor:
But it returns error :
It is on a single instance of node process, I have not multiple. Redis: v 4.0.7 Node : v 9.9.0 Socket.io : v 2.0.4 Socket.io-redis : v 5.2.0
Hi. I have similar problem when use ioredis cluster, if i use just one redis node, all work good.
Node version 6.9.1. ioredis version 3.1.1 socket.io version 2.0.3, socket.io-redis version 5.2.0
Here’s error stacktrace:
Code where error occurs:
Here are the detailed Redis logs for the cluster with 3 nodes: first node
second node
third node
And logs fore one node:
Sometimes there is no error, but more often.
I was able to fix this in my project. Here is what I was using before to connect the adapter:
This was written before I took over the project, so I can’t say why it’s using 2 clients for pub and sub, but it explains why it was working locally but not in production mode. Changing that to the following fixed it:
Why this started to fail when we switched to yarn, I have no idea.
@Natashkinsasha Are you using an AWS ElastiCache? In this case you could try the following code:
instead of using “new ioredis.Cluster()”, that worked for me.
Just be careful if you use redlock as well, for redlock you want to use
lockClient = new ioredis.Cluster([options]);but not for socket.io-redis.Source: https://github.com/luin/ioredis/issues/432 (well, and the code above worked for me at least)
how to resolve this?
mark
Hello. Any progress ?
I have this issue as well… is there an update on this? i’d really not prefer to write a custom function to manage sockets in a room. This works fine on single instance redis, only an issue for me when using cluster.