# Half-open TCP connection on HL6528RD

**URL:** <https://forum.sierrawireless.com/t/half-open-tcp-connection-on-hl6528rd/20003>\
**Category:** Legacy HL Series\
**Created:** [April 7, 2020, 1:04pm UTC](https://forum.sierrawireless.com/t/half-open-tcp-connection-on-hl6528rd/20003 "2020-04-07T13:04:55Z")\
**Posts on this page:** 4\
**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:** [April 7, 2020, 1:04pm UTC](https://forum.sierrawireless.com/t/half-open-tcp-connection-on-hl6528rd/20003/1 "2020-04-07T13:04:55Z")

</div>

Hi all,

I’m using HL6528RD to implement an MQTT client over TCP socket. Sometimes I got a strange behaviour: my module seems to be connected to the remote server, it sends topics but nothing is received remotely. I suspect an half-open connection is happening.  
Is there is any way to detect an half-open TCP connection by reading the TCP socket status (AT+KTCPSTAT)?  
Is this behaviour more frequent over a mobile network? If so, how can I reproduce it sistematically?

Thanks and regards,  
Sabino

---

<div class="post-metadata">

**Author:** ![Vianney](https://avatars.discourse-cdn.com/v4/letter/v/71e660/32.png) [@Vianney](https://forum.sierrawireless.com/u/Vianney)\
**Post date:** [April 8, 2020, 9:58am UTC](https://forum.sierrawireless.com/t/half-open-tcp-connection-on-hl6528rd/20003/2 "2020-04-08T09:58:18Z")

</div>

Hi @sabinocolonna,  
There are some reasons relating network problem/proccess crash,…etc cause half-open TCP connection. You can refer to below link for common cases.

> **[Detection of Half-Open (Dropped) Connections](https://blog.stephencleary.com/2009/05/detection-of-half-open-dropped.html)**
>
> There is a three-way handshake to open a TCP/IP connection, and a four-way handshake to close it. However, once the connection has been established, if neither side sends any data, then no packets are sent over the connection. TCP is an “idle”...

On module you can enable _+KTCP\_ACK Notification_ to see the status report for TCP data. It will show Data sent failure/success (all the data has (NOT) been received by the remote side)  
Example

> at  
> OK  
> at+kcnxcfg=1,“gprs”,“internet”  
> OK  
> at+ktcpcfg=1,0,“[google.com](http://google.com)”,80,123,1,1  
> +KTCPCFG: 1
> 
> OK  
> at+kcnxup=1  
> OK  
> at+ktcpcnx=1  
> OK
> 
> +KTCP\_IND: 1,1  
> at+ktcpsnd=1,9  
> CONNECT
> 
> NO CARRIER
> 
> +KTCP\_NOTIF: 1,8
> 
> +KTCP\_NOTIF: 1,0
> 
> +KTCP\_NOTIF: 1,4
> 
> +KTCP\_ACK: 1,0
> 
> OK  
> **+KTCP\_ACK: \<session\_id\>,**   
> Parameters  
> **\<session\_id\>** TCP session index  
> \<result\>  
> 0 Data sent failure: not all data has been received by remote side  
> 1 Data sent success: all the data has already been received by the remote side

Please refer to 13.9.1. +KTCPCFG Command: TCP Connection Configuration. page #516 in the AT command which was posted [here](https://source.sierrawireless.com/resources/airprime/software/airprime_hl6_and_hl8_series_at_commands_interface_guide/#sthash.vq2b7Lg2.dpbs)  
Also you can check by using _KTCPACKINFO Command: Poll ACK Status for the Latest Data_

> AT+KTCPACKINFO=\<session\_id\>

Please feel free share any concerns you have. Help us tick **Solution** if your question is answered  
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:** [April 9, 2020, 1:58pm UTC](https://forum.sierrawireless.com/t/half-open-tcp-connection-on-hl6528rd/20003/3 "2020-04-09T13:58:59Z")

</div>

Hi @Vianney,

Thanks for your reply.  
I already poll (every 100ms) the TCP socket status by means of _+KTCPSTAT_ command and check for both **status** and **tcp\_notif** fields:

- I assume the socket is OK only if **status** is 3, and **tcp\_notif** is -1 or 8;
- I assume the socket is KO in any other case.

I don’t use _+KTCPACKINFO_ command since it requires URCs to be enable and I disabled them.  
Is this ok for detecting an half-open TCP connection (and any other possible TCP failures)?

Moreover, I’m using the MQTT keepalive mechanism to be sure that anyone on the other side is still alive, forcing a TCP reconnection if PINGRESP packet is not received within a timeout. Can this be a good solution?

Thanks and regards,  
Sabino

---

<div class="post-metadata">

**Author:** ![Vianney](https://avatars.discourse-cdn.com/v4/letter/v/71e660/32.png) [@Vianney](https://forum.sierrawireless.com/u/Vianney)\
**Post date:** [April 13, 2020, 9:45am UTC](https://forum.sierrawireless.com/t/half-open-tcp-connection-on-hl6528rd/20003/4 "2020-04-13T09:45:54Z")

</div>

Hi @sabinocolonna,  
It’s good when you set poll (every 100ms) the TCP socket status and force TCP reconnection if packet is not received within a timeout.  
Thanks
