-->
Page 1 of 2

TCP connection disconnected after 10 second idle

PostPosted: Thu Jul 09, 2015 9:13 pm
by kolban
I have my ESP8266 accepting incoming TCP connections. I have a socket client running on a PC connecting to the ESP8266. It sends 100 bytes of data and then sleeps for a minute. Explicitly, it does NOT close the socket. On the ESP8266, the connection is seen to happen and we receive all the data as evidenced in the receive callback. However, exactly 10 seconds after the last receive, the ESP8266 disconnect callback is invoked and the connection is shutdown at the ESP8266 side. If I keep sending a few bytes every few seconds, then the ESP8266 connection stays active.

What I conclude from this is that the ESP8266 seems to automatically close a TCP connection if there has been no traffic over it for a period of 10 seconds or more. I haven't seen that documented as semantics. Has anyone any information of this apparent situation?

... Later ...
After some more study, I have located a function call called espconn_regist_time() which I think specifies an idle timeout on TCP connections. This may explain what I am seeing.

Neil

Re: TCP connection disconnected after 10 second idle

PostPosted: Sat Jul 11, 2015 7:53 pm
by tve
Yup, you found it ;-)

Re: TCP connection disconnected after 10 second idle

PostPosted: Sat Jul 25, 2015 8:06 am
by dp01
I am getting same problem. Did someone get any solution?

Re: TCP connection disconnected after 10 second idle

PostPosted: Sat Jul 25, 2015 8:40 am
by kolban
Howdy,
I updated the 1st post of this thread. The TCP disconnect after 10 seconds is only the default. You can use the function called:

espconn_regist_time()

to change the disconnect interval. The maximum value is 7200 seconds (2 hours). See the SDK docs for details.

Neil