socket.io-redis-adapter icon indicating copy to clipboard operation
socket.io-redis-adapter copied to clipboard

A more robust way to gather facts from nodes

Open doodlesbykumbi opened this issue 3 years ago • 7 comments

I have a local setup with Redis and some application nodes. I have another redis client that is snooping on the channels that the adapter is using.

Whenever I'm snooping I get this error:

Error: timeout reached while waiting for sockets response

I looked into it and this error is because while snooping request.numSub > request.msgCount since my other client is just a spy. It would be nice if observing the channel didn't break the functionality. Perhaps there could be a way to count participant subs only. https://github.com/socketio/socket.io-redis-adapter/blob/3242d8e91baf94720df256ab422ec5c037f6a9e1/lib/index.ts#L380-L386

doodlesbykumbi avatar May 17 '21 21:05 doodlesbykumbi

Perhaps there could be a way to count participant subs only.

I'm open to suggestions on this!

darrachequesne avatar May 17 '21 22:05 darrachequesne

I'll think about it a bit and see if I can suggest anything useful.

doodlesbykumbi avatar May 17 '21 22:05 doodlesbykumbi

@darrachequesne, so here's an idea. We can have the "active" participants subscribe to a "proxy" channel when they come online. Nothing actually goes through that particular channel, it's just used for a participant to explicitly mark themselves as a participant.

doodlesbykumbi avatar May 17 '21 22:05 doodlesbykumbi

@doodlesbykumbi that's an interesting idea. That would be a backward incompatible change though, which means users will need to upgrade the whole cluster at the same time, isn't it?

darrachequesne avatar May 18 '21 21:05 darrachequesne

@darrachequesne You can fall back to the request channel for backwards compatibility if desired.

doodlesbykumbi avatar May 18 '21 22:05 doodlesbykumbi

I've created a PR to demonstrate the approach^

doodlesbykumbi avatar May 18 '21 22:05 doodlesbykumbi

Ping @darrachequesne

doodlesbykumbi avatar May 24 '21 15:05 doodlesbykumbi