Simulating a TCP Keep-Alive Message in OmniServer
I am using a serial-to-Ethernet converter to communicate with my serial device using OmniServer. Communications are successful until there is an interruption in power or a connection break with the serial-to-Ethernet converter. How can I configure my OmniServer project to reestablish communications with the converter once the connection has been restored?
This problem is caused by the fact that OmniServer has no way of knowing that the TCP connection has been broken. If it is possible to send a single character (such as a character return) to your device without affecting communications, a Keep-Alive message will cause OmniServer to retry the connection, eliminating this problem.
For the keep-alive message, all you have to do is add the following to your protocol file:
- Create a new host message (You can name it anything you like - something descriptive like "Heartbeat", for example)
- Set the "Type" = "Read". This is very important.
- Check the box labeled "Message should be automatically activated". This, too, is very important.
- Click on the "Request" tab.
- Type in the following:
{$CR}
...and click OK.
Then, on your Topic, set the Update Interval to the number of milliseconds that need to lapse between polls. For one minute, set the time to 60000. If you'd like the heartbeat to be more frequent than this, you can lower the interval. Save the protocol to complete the necessary configuration.
Not all devices will support a keep-alive message and send a keep-alive character can interrupt communications if that is the case.