Hi There,
Another one of those "why is it so" questions.
Three tcp in nodes that connect to the same host/port combination. Initially all are disconnected, then when I start the service (i.e., netcat on 9393 - (while date ; do sleep 1 ; done) | nc -lk -p 9393
), one node will randomly connect and produce time stamps messages.
I've been implementing the tcp nodes over at Erlang-Red and changed that behaviour to be the following:
All three tcp in nodes connect to the server and receive the same data. There aren't three separate connections, there is one single connection with the data being routed to all three nodes. (Behind the scenes, a centralised connection manager maintains a "routing" table and ensures that there is a single connection.)
All three tcp nodes receive the same data from the source with the same session id but they generate three different messages (differing message ids) containing the same payload.
I actually quite like this behaviour of having all tcp in nodes receiving the same data - I know that it's confusing and it shouldn't be done because .... <--- why though? That's where I got lost.
Also accidentally having multiple tcp in nodes with the same host/port combination is probably not that unlikely and then having a random node make the connection and receive the data is probably also confusing - IMHO.
So the question is, is there a reason for the Node-RED behaviour or is it simply a consequence of the implementation? Node-REDs node behaviours are unfortunately not standardised (something that I believe should change) so there is no explanation that I can find.