찾아보니 Keep Alive를 활용 하는 글이 있었습니다만…
링크—>[From QnA]TCP Keep Alive Option
===========================================================================
To set the keep alive function you need to use below command.
AT+SETSOCKOPT=,
Regarding the SETSOCKOPT, please refer to below information.
- CID: is the socket identifier received after opening a connection.
- Type: is the type of the option to be set
(SOCKET: 65535, IP : 0, TCP: 6) - Parameter: The Option name to be set. Accepts hex values.
(TCP_MAXRT : 10(Hex), TCP_KEEPALIVE: 4001(Hex), SO_KEEPALIVE: 8(Hex), TCP_KEEPALIVE_CNT: 4005(Hex)) - Value: The value to be set. This in seconds (Ex: 30 ? 30 seconds)
- Length: The length of the value in bytes (Ex: in above case it is 4, basically it tells the type of the value is integer, Short or Char) (Integer : 4, Short : 2, Char :1)
This command returns the standard command response (paragraph heading Commands for Command Processing Mode in this chapter) to the serial interface.
To enable the TCP Keepalive is:
AT+SETSOCKOPT= 0,65535,8,1,4 : Enable SO_KEEPALIVE option at base socket level. Without enabling this TCP_KEEPALIVE will not work.
AT+SETSOCKOPT= 0,6,4001,600,4 : Enable TCP_KEEPALIVE option at TCP level with timeout as 600 seconds.
Note: The default keepalive count is 8 so the minimum keepalive timeout is 8*75=600 seconds. To reduce the keepalive timeout further, set the Keepalive count first to an appropriate value and set the keepalive timeout.
Ex: To set the keep alive timeout to 75 seconds:
AT+SETSOCKOPT =0,6,4005,1,4 : Configure TCP Keep Alive Probe Sending count at just 1.
AT+SETSOCKOPT= 0,6,4001,75,4 : Enable TCP_KEEPALIVE option at TCP level with 75 seconds as Keep Alive timeout.
===========================================================================
이 설정을 해도… 역시나 소켓 해제가 잘 안되더라구요…
가만히 있으면 소켓이 아주 랜덤한 시간으로… [ERROR SOCKET FAILURE]을 띄우긴 하는데…
너무 랜덤해서… 제품에 적용하기가… ㅠㅠ