# TCP status on HL6528RD

**URL:** <https://forum.sierrawireless.com/t/tcp-status-on-hl6528rd/18900>\
**Category:** Legacy HL Series\
**Created:** [January 7, 2020, 3:38pm UTC](https://forum.sierrawireless.com/t/tcp-status-on-hl6528rd/18900 "2020-01-07T15:38:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![sabinocolonna](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@sabinocolonna](https://forum.sierrawireless.com/u/sabinocolonna)\
**Post date:** [January 7, 2020, 3:38pm UTC](https://forum.sierrawireless.com/t/tcp-status-on-hl6528rd/18900/1 "2020-01-07T15:38:19Z")

</div>

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”](https://forum.sierrawireless.com/t/tcp-session-with-hl6528/14282).

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

---

<div class="post-metadata">

**Author:** ![jerdung](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jerdung](https://forum.sierrawireless.com/u/jerdung)\
**Post date:** [January 8, 2020, 3:52am UTC](https://forum.sierrawireless.com/t/tcp-status-on-hl6528rd/18900/2 "2020-01-08T03:52:00Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![sabinocolonna](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@sabinocolonna](https://forum.sierrawireless.com/u/sabinocolonna)\
**Post date:** [January 9, 2020, 8:12am UTC](https://forum.sierrawireless.com/t/tcp-status-on-hl6528rd/18900/3 "2020-01-09T08:12:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jerdung](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jerdung](https://forum.sierrawireless.com/u/jerdung)\
**Post date:** [January 9, 2020, 9:29am UTC](https://forum.sierrawireless.com/t/tcp-status-on-hl6528rd/18900/4 "2020-01-09T09:29:43Z")

</div>

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

Thanks

---

<div class="post-metadata">

**Author:** ![sabinocolonna](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@sabinocolonna](https://forum.sierrawireless.com/u/sabinocolonna)\
**Post date:** [January 9, 2020, 10:03am UTC](https://forum.sierrawireless.com/t/tcp-status-on-hl6528rd/18900/5 "2020-01-09T10:03:15Z")

</div>

Hi,

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

Regards,  
Sabino

---

<div class="post-metadata">

**Author:** ![jerdung](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jerdung](https://forum.sierrawireless.com/u/jerdung)\
**Post date:** [January 10, 2020, 3:09am UTC](https://forum.sierrawireless.com/t/tcp-status-on-hl6528rd/18900/6 "2020-01-10T03:09:33Z")

</div>

Hi,  
For Ubuntu, if you are using tcpserver command you can use -t option  
[http://manpages.ubuntu.com/manpages/xenial/man1/tcpserver.1.html](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,

---

<div class="post-metadata">

**Author:** ![sabinocolonna](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@sabinocolonna](https://forum.sierrawireless.com/u/sabinocolonna)\
**Post date:** [January 17, 2020, 10:18am UTC](https://forum.sierrawireless.com/t/tcp-status-on-hl6528rd/18900/7 "2020-01-17T10:18:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jerdung](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jerdung](https://forum.sierrawireless.com/u/jerdung)\
**Post date:** [January 21, 2020, 6:04am UTC](https://forum.sierrawireless.com/t/tcp-status-on-hl6528rd/18900/8 "2020-01-21T06:04:29Z")

</div>

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](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/](https://askubuntu.com/)

Thanks so much.

---

<div class="post-metadata">

**Author:** ![sabinocolonna](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@sabinocolonna](https://forum.sierrawireless.com/u/sabinocolonna)\
**Post date:** [January 21, 2020, 8:26am UTC](https://forum.sierrawireless.com/t/tcp-status-on-hl6528rd/18900/9 "2020-01-21T08:26:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jerdung](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jerdung](https://forum.sierrawireless.com/u/jerdung)\
**Post date:** [January 21, 2020, 9:34am UTC](https://forum.sierrawireless.com/t/tcp-status-on-hl6528rd/18900/10 "2020-01-21T09:34:04Z")

</div>

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
