TCP status on HL6528RD

Hi,

I’m using HL6528RD modem to implement an MQTT client over a TCP socket.
The TCP socket status is polled every 100ms to check if any data is available to read.

The TCP socket is open at application startup and keeps opened until I decide to close the MQTT connection.
I noticed that every 150 sec (more or less), the +KTCPSTAT command returns 5 as , i.e. “Socket is closed”. In such a situation, I close the socket and reopen it as suggested in this thread: “TCP session with HL6528”.

My question is: why the socket gets closed every 150 sec (if I don’t have any activity on it)? Is it some TCP timeout related to the network operator? Is there any way to control/avoid it?

Thanks and regards,
Sabino

Hi sabinocolonna,
TCP timeout is configured by TCP server ( if there is not any activity, after this timeout server will close the session). If you manage this server, you can change this value. If not, please add code in your application to send something to server before that timeout. This value is not related to network or module.
Thanks,

Hi jerdung.

Thanks for your reply. Please, could you give me an hint about which TCP parameter should be checked and modified on server side?

Regards,
Sabino

Hi,
What is the kind of TCP server that you are using ( python, or lua or…)?

Thanks

Hi,

We are using a Linux Ubuntu 16.04.6 machine, so the TCP server is embedded in the OS kernel stack.

Regards,
Sabino

Hi,
For Ubuntu, if you are using tcpserver command you can use -t option
http://manpages.ubuntu.com/manpages/xenial/man1/tcpserver.1.html

If you are using “nc” command -w option is used for timeout.

If it can help, please click to Solution, so that community can find their solution easily.

Thanks,

1 Like

Hi,

Here below the settings on our server:

  • tcp_keepalive_time: 7200
  • tcp_keepalive_intvl: 75
  • tcp_keepalive_probes: 9

Could you suggest a different setting to avoid socket shutdown on client side? I already have a 30 secs keepalive mechanism at application layer: reducing it at 2 mins solves the problem but I’d like to keep it as long as possible and bypass TCP keepalive.

Thanks in advance,
Sabino

Hi,
With your configuration, the TCP session timeout is 2 hours. Please make sure that these values are set correctly.
http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/usingkeepalive.html

If you need a support on TCP server, you can raise ticket in Ubuntu forum https://askubuntu.com/

Thanks so much.

Hi,

Thanks for the reply. It was the same doubt I had. But here are other questions:

  1. May it be that TCP timeout settings are different on the intermediate network equipment and these may impact on the socket shutdown?
  2. If the server implements a TCP keepalive strategy, why the TCP stack inside the HL6528RD modem does not respond to the probing packets coming from the server?

Thanks and regards,
Sabino

Yes, the network equipment can kill the idle TCP socket, such as firewall, so these devices may impact on the socket shutdown.
And HL6 series do not provide any AT interface to config keepalive. Please enable KTCP_ACK in KTCPCFG command to check if any URC is returned or not.
AT+KTCPCFG= [], , [], <tcp_port>[, [<source_port>]
[<data_mode>],
[]], [<SSL profile]
with URC-ENDTCP-enable = 1

Thanks

1 Like