Half-open TCP connection on HL6528RD

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

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.

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”,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
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

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

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

2 Likes