TCP/IP bi-directional messaging

Hi there, not sure I'musing correct words to describe exactly what I mean. Apologies.

Does node red support bidirectional messaging with existing nodes. (Without the request-response approach)?

I'm struggling to set it up. What I need is a code for

1)setting up the connection when a client outside connects to it
2)sending to client
3)receiving from client

What problems I have encountered in setting up Node red Windows Version 4.0 to talk to Labview using tcp/ip. Its older version of labview without mqtt.
In my current workflow I can achieve the labview being a client and node-red being a server.
labview is initiating the request and node red is replying. I can get data sent this approach both ways when client is initiating things. But would like to be able ideally asynchronously exchange data from either side. using tcp ip.

Could someone share the code, would be very grateful.

Kind Regards

Hi @kubasmyk

If I have this right, this is what you need to do...

Create 2 Nodes

  • TCP IN (Set to Listen On)
  • TCP OUT (BUT set it to Reply to TCP)

Connect a Status Node to TCP IN - why? because you can store the _session object representing the client's connection when they connect.

THEN

  • Send to any client using TCP OUT
    appending _session to the msg object - you will need to engineer a state object to manage clients. omitting _session sends to all clients

when a client sends, and you need to respond, just ensure you include the correct _session in the outgoing msg

I have added the _session id to the object before sending and it worked. Thank you