Close half-open sockets

Hi,

I am fairly new to NodeRed - I would like to know how to implement the following in NodeRed:

  • I am using a TCP Server to receive incoming connections from various devices.
  • Since we are operating over a 'lossy network' ( cellular network) , we have implemented an
    application layer exchange of periodic 'Health check' messages to ascertain if the device is
    'online' or not.
  • This is to prevent 'half-open' sockets build-up on the server side.
  • If no HC messages are received from the device for a period of 1 min, we close the socket on the server side so that there is no build-up of 'half-open' sockets.

I am trying to implement the above in NodeRed. I am using a TCPserver node for devices to connect to and receive the msg payload. However, how do I reference the socket that a specific device is connected to so that I can close it if I haven't received health check messages for some time period?

Looking forward to some help on how to about doing this in NodeRed.

My advice would be use a protocol designed for "poor" networks. If you can, use MQTT and forget about all the packet parsing, half close/hung sockets etc. MQTT just does its thing.

If not then you might have to code it all yourself in a function node by importing a socket library like node:net

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