RCM6760 Detect Ethernet cable disconnected

I’m attempting to create more robust TCP/IP connections to our Rabbit RCM6760. It maintains a passive connection where application software connects and stays connected for long periods of time transferring data back and forth via a raw TCP connection. It works fine under most operating conditions.

We are having some issues with the connection locking up, where there is a connection error of some type and we cannot re-connect even after closing the application software. These are still being diagnosed on the software side, but it would be good for our Rabbit to take a more active role in analyzing the status of the connection and closing it if it’s in a strange state.

Most specifically, I noticed tcp_tick() and sock_fastread() don’t seem to detect when the ethernet cable is disconnected. I found this post:
that recommends using pd_havelink() to detect that condition at least, but I’m surprised tcp_tick() and sock_established() don’t call this at a lower level before checking for new data. Or if they do, I’m not aware of the right status to check that’s updated/returned by them.

Are there general tips for maintaining a robust connection using the Rabbit’s tcpip API?

Conditions we can ideally detect:

  • Ethernet cable disconnected from Rabbit (can do using above)
  • No connection to a network (Ethernet cable disconnected past a switch/hub, or no other devices on network)
  • Application software has attempted to disconnect, but has done so incompletely (*RST packets have at least been sent both directions)

Any help is appreciated, thanks!

  • James

After further research, it looks like the only two real options in our use case are:

  • pd_havelink() to detect immediate physical connection being lost
  • tcp_keepalive() to detect anything between the Rabbit module and the application being lost

This works for us since we’re always on closed networks and don’t have a heavy load, so keepalive packets every 60sec or so won’t hurt. Our connections tend to be persistent, anyway.

Are there any other things I should be aware of using tcp_keepalive(), other than increased network usage?


1 Like

Started my answer and then saw your response waiting in the moderation queue.

Yes, tcp_keepalive() is a good solution for detecting a TCP socket going down. It should add minimal network usage, but usage might be a consideration if you’re on a cellular network.