Skip to content

serverSideEmit with ack question #431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yanush opened this issue Dec 6, 2021 · 4 comments
Closed

serverSideEmit with ack question #431

yanush opened this issue Dec 6, 2021 · 4 comments

Comments

@yanush
Copy link

yanush commented Dec 6, 2021

I have multiple nodejs services, all of which are connected to the same socket.io-redis-adapter.
I want to be able to send messages between these services with acknowledgement using serverSideEmit.
My problem is the next scenario:
Let's say I have 3 nodejs services - s1, s2, s3.

Both s1 and s2 are sending the same message m1 to a namespace which is also called m1 (for the sake of simplicity): io.of(/m1).serverSideEmit(m1, data, (error, responses) => {})

I want only s3 to subscribe to m1 namespace.
The problem with the current implementation, is that after s1 sends m1, and s2 sends m1, we now we have 3 subscribers to m1 namespace (s1, s2, s3), but only s3 is set to ack this message:
io.of(/m1).on(m1, (data, callback) => {})

any service that sends m1 (either s1 or s2) is waiting for 2 responses (since it has 3 subscribers), but it only gets 1 response (from s3), and keeps throwing errors due to timeout

How can I work around this issue?

@yanush yanush closed this as completed Dec 6, 2021
@yanush yanush reopened this Dec 7, 2021
@yanush
Copy link
Author

yanush commented Dec 9, 2021

If there was an option to override numsub (since I know how many responses I should get) with a param given to serverSideEmit then it would solve this issue

@darrachequesne
Copy link
Member

Well, can't you just... ignore the timeout? Or send an empty reply from the other services?

@yanush
Copy link
Author

yanush commented Dec 16, 2021

I could, but it's kind of weird that the sender needs to reply to its own messages.
Anyway, I have built a different system for it based on redis streams.
I wanted to use it as an IPC replacement but I have already managed to achieve it.
Thanks

@darrachequesne
Copy link
Member

Closed due to inactivity, please reopen if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants