My use case is the following one, I have N workers, with X sockets connected to them, I want to publish an event to all workers, which will then emit an event to all connected sockets (via transmit). This is needed because someone connected to one of the workers, can modify some state that needs to be updated on everyone connected to the server, however, this change must pass on the server first (so I cannot simply publish to some channel every client subscribes to). My idea was to simply publish to some channel using agServer.exchange.transmitPublish, which every worker listens to via agServer.exchange.subscribe, then each one would consume this event and forward it to the connected sockets, like this:
// ...
for (const socket of Object.values(agServer.clients)) {
socket.transmit('some-receiver', someData)
}
// ...
But this is not working, only the worker that published the message receives it. What I'm doing wrong? I recall this workflow worked with Socketcluster.
All this is using the latest version deployed directly to Kubernetes with 1 agc state, 1 broker and 3 workers.
@jondubois first, thanks for the amazing library!
My use case is the following one, I have N workers, with X sockets connected to them, I want to publish an event to all workers, which will then emit an event to all connected sockets (via transmit). This is needed because someone connected to one of the workers, can modify some state that needs to be updated on everyone connected to the server, however, this change must pass on the server first (so I cannot simply publish to some channel every client subscribes to). My idea was to simply publish to some channel using
agServer.exchange.transmitPublish
, which every worker listens to viaagServer.exchange.subscribe
, then each one would consume this event and forward it to the connected sockets, like this:But this is not working, only the worker that published the message receives it. What I'm doing wrong? I recall this workflow worked with Socketcluster.
All this is using the latest version deployed directly to Kubernetes with 1 agc state, 1 broker and 3 workers.