Comments (5)
Hi! If I understand correctly, you have a cluster of servers, some in v2.5.0 and some in v4.7.1.
I think the problem is that the fetchSockets()
operation was added in v4, so the v4 server sends the operation to all the servers but only other v4 servers respond, so the operation times out (even though the server has received all necessary responses).
Not sure how to handle this though. Maybe some kind of feature detection?
from socket.io-redis-adapter.
I am seeing this as well
from socket.io-redis-adapter.
me too
from socket.io-redis-adapter.
Any updates ???, still encountering the same issue
from socket.io-redis-adapter.
I was gonna make an issue but I'm glad this is here. This comment is just a investigation "report" of the code and why it behaves this way (AFAIK)
First of all I'm not a pro at redis.
My best guess is there are multiple things to consider and investigate. Some steps to consider:
-
Use the
timeout()
function to test and see if the cause of the issue is really just the request taking too longio.timeout(20000).fetchSockets()
-
If (1) didn't work, maybe have a check somewhere to keep checking the heartbeat of all your instances?
-
Check your redis connection in each instances?
These lines below handle the response and expects (waits for) K number of responses. So if you have 3 instances running, it will expect 2 response (3 - self) and will not clear the timeout until all responses are received.
https://github.com/socketio/socket.io-redis-adapter/blob/cdb55353f83c78cabe9788683e4dd93ac4cd50c9/lib/index.ts#L553C1-L559C10
This is the code that generates the timeout error (for reference):
Note that this will unconditionally throw an error;
My point (3) is arguably the least possible, but never says never. The reason I'm saying this is because the number of responses expected K is generated via
socket.io-redis-adapter/lib/index.ts
Line 736 in cdb5535
which uses redis.
TLDR:
- We get number K of remote instances
- Send a request to all instances + start a timeout
- As we receive responses from all instances, we check if number of responses (H) received = K
- if H = K --> clearTimeout; Else do nothing
Take away:
For the timeout not too clear, at least a single remote instance has to fail responding.
My proposed solution to maintainer:
If at least one instance sent a valid response, instead of a throwing an error "timeout reached while waiting for fetchSockets response" we should still resolve the promise and log a warning "fetchSockets : Only H responses received within timeout, expected K"
from socket.io-redis-adapter.
Related Issues (20)
- Retrieving number of connected sockets using `fetchSockets` without getting all socket information HOT 5
- Make subscription client optional HOT 1
- Proper way to use this adapter with ioredis HOT 2
- Feature request: limit nodes hit by "serverSideEmit" and "fetchSockets" in sharded adapter
- Error on websocket multi instance using redis-adapter HOT 1
- This.io.sockets.adapter.pubClient.isReady becomes false and is never ready again HOT 2
- Error: 23984 trailing bytes HOT 5
- dynamic subscription mode breaks remote socket.emit() HOT 3
- [email protected]: timeout reached while waiting for fetchSockets response
- MaxListenersExceededWarning due to SSUBSCRIBE/SUNSUBSCRIBE memory leak HOT 2
- the below error occurs when the user disconnect from the socket HOT 1
- the below error occurs when the user disconnect from the socket HOT 1
- Socket.io adapter HOT 1
- TypeError with @socket.io/redis-adapter on Node.js v18.15.0 HOT 5
- Lot of "ignoring unknown request" in Debug HOT 5
- Unnecessary psubscribe Operations in Namespaces Without Local Clients Increasing Redis Pub/Sub Channels HOT 2
- Unnecessary on("error") handlers
- Class extends value undefined is not a constructor or null HOT 3
- Cannot install package with 'npm install @socket.io/redis-adapter' HOT 1
- fetchSockets doesn't work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from socket.io-redis-adapter.