-
Notifications
You must be signed in to change notification settings - Fork 10
Description
this could possibly be a documentation bug or perhaps am doing something wrong.
through my tests, it was revealed that the broadcast messages are only sent to clients connected to the same node process and not to the "cluster" as is mentioned in the documentation.
Here is whats written: "Broadcast a message to all sparks in the cluster."
I tested by using two node processes behind HAProxy. I fired up two browser sessions and made sure clients were connected to separate node processes. I sent messages and only received them back on the sender but the other client that was connected to the other node process did not receive anything.
I killed one of the node processes and forced the client connected to it to use the other node process (behind HAProxy). This time I could see that messages were received on both clients (because both were connected to the same process now).
The code I used to broadcast message is:
primus.forward.broadcast( data.message, function (err, result) {
logger.debug("In send message: " + JSON.stringify( result ) +
" error: " + JSON.stringify( err ));
});
The debug line returned (after a few minutes of sending message).
debug: In send message: [null] error: {"code":"ECONNRESET","url":"http://192.168.1.9:3000/primus/omega/supreme","status":500,"body":{},"type":"broadcast","packet":{"sparks":"","msg":"hello"}}
Its the same error object that is returned no matter if the messages were delivered or not.