Skip to content

serverSideEmit with ack question #431

Closed
@yanush

Description

@yanush

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions