FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
483 views 1 comments
by anonymous

Hello,
I would like to establish a serial connection from a PC to a remotely located data logger. The TRB142 (firmware TRB1_R_00.07.01.2) provides the serial port in the field, and on the controlling PC a virtual COM port with TCP/IP socket is set up with hub4com/com0com (https://sourceforge.net/projects/com0com/files/hub4com/).

The RS232 port on the TRB142 is configured as Over IP, Protocol: TCP, Mode: Client, Port: xyz, Reconnect Interval: 10s
This works very well at first and I can control and read out the data logger from the PC.
After some time the connection breaks, and with some effort I found the cause: The TRB142 establishes new TCP connections in regular intervals!

You can follow this well with the port monitor CurrPorts, see screenshot. First the communication works (you can see this in the second line, Sent/Received Bytes). Then in intervals of about 30 minutes (with further attempts it was also 12 minutes) new TCP connections are established, a communication is no longer possible.

If you delete the older existing TCP connections except the current one manually with CurrPorts, you can communicate again, until the TRB142 establishes an additional TCP connection again. Or you restart hub4com each time.
What can be done to prevent this behavior? The cause seems to be the TRB142 alone, the multiple connections happen without anything being connected to its RS232 port.

Regards

1 Answer

0 votes
by anonymous
My guess is that your TCP connection is flushed from the NAT table in one of the routers between the TRB device and the computer with the virtual comport. To prevent this from happening the device will send empty TCP packets every 2 minutes to check if the connection is valid (tcp keepalive). But most modern NAT devices will not keep TCP connections in the table from those empty packets without data.

The value for TCP NAT timeout varies between different operators and network setup. I've seen values as low as a few minutes. Try sending some data, in either direction, every minute to see if the problem stops. If successful any data usage is critical try doubling the interval until the problem comes back and stay below this interval.
by anonymous
Thank you for your suggestion, I think you're right. Connecting the TRB142 to a TCP socket as a serial port client is not a direct replacement for a serial cable. There's a reason that expensive Cellular Gateways with special COM Port drivers exist.