Basic TCP question - server sending message to client

Greetings All!

I have a working example up and running, using an ESP32 as a TCP client connected with a TCP server node in node red (running on a raspberry pi). The client sends basic messages to the server, and I can see these received messages in node red with the debug node (Great! So far, no problems).

Now, is there an example for sending a message from the server to the client? For instance, let's say I create a node red dashboard on the TCP server, and when a user clicks a button on the dashboard, a message is sent from TCP server to TCP client to "set GPIO3 high on the ESP32". Is there a way to do this?

Yes, certainly. Use a tcp-out node to send whatever data you like (in the payload) to a tcp-in node on the other instance of Node-RED.

Just take care what port you choose. Typically, you need a free port >1024. You may wish to check online to make sure that the port is not used in another common service.

Most people trying this however, move on to MQTT quite quickly since an MQTT connection to a broker is a lot more resilient.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.