GithubHelp home page GithubHelp logo

Comments (5)

darrachequesne avatar darrachequesne commented on June 8, 2024

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.

cody-evaluate avatar cody-evaluate commented on June 8, 2024

I am seeing this as well

from socket.io-redis-adapter.

introspection3 avatar introspection3 commented on June 8, 2024

me too

from socket.io-redis-adapter.

HannaSamia avatar HannaSamia commented on June 8, 2024

Any updates ???, still encountering the same issue

from socket.io-redis-adapter.

Benjythebee avatar Benjythebee commented on June 8, 2024

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:

  1. Use the timeout() function to test and see if the cause of the issue is really just the request taking too long io.timeout(20000).fetchSockets()

  2. If (1) didn't work, maybe have a check somewhere to keep checking the heartbeat of all your instances?

  3. 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):

https://github.com/socketio/socket.io-redis-adapter/blob/cdb55353f83c78cabe9788683e4dd93ac4cd50c9/lib/index.ts#L755C1-L763C32

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

const numSub = await this.serverCount();

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.