ESP8266 Developer Zone The Official ESP8266 Forum 2017-03-31T03:39:04+08:00 https://bbs.espressif.com:443/feed.php?f=66&t=1439 2017-03-31T03:39:04+08:00 2017-03-31T03:39:04+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1439&p=11765#p11765 <![CDATA[Re: the keep alive seem failed.]]> Statistics: Posted by pwolf — Fri Mar 31, 2017 3:39 am


]]>
2015-12-09T14:46:37+08:00 2015-12-09T14:46:37+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1439&p=4961#p4961 <![CDATA[Re: the keep alive seem failed.]]>
Please have a try with the "liblwip_nonOS_SDK_v1.5.0.zip" I provided above.

If your problem is still unsolved, please feel free to let us know.

Statistics: Posted by ESP_Faye — Wed Dec 09, 2015 2:46 pm


]]>
2015-12-07T08:46:05+08:00 2015-12-07T08:46:05+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1439&p=4923#p4923 <![CDATA[Re: the keep alive seem failed.]]> sorry, i don't known "liblwip_nonOS_SDK_v1.5.0.zip", but i use No OS SDK. it's esp_iot_sdk_v1.5.0_15_11_27.zip and esp_iot_sdk_v1.4.1_pre2_15_10_22.zip.

Statistics: Posted by wjzhang — Mon Dec 07, 2015 8:46 am


]]>
2015-12-04T16:32:10+08:00 2015-12-04T16:32:10+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1439&p=4895#p4895 <![CDATA[Re: the keep alive seem failed.]]>
Did you use the "liblwip_nonOS_SDK_v1.5.0.zip" above ?

Statistics: Posted by ESP_Faye — Fri Dec 04, 2015 4:32 pm


]]>
2015-12-04T15:35:13+08:00 2015-12-04T15:35:13+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1439&p=4892#p4892 <![CDATA[Re: the keep alive seem failed.]]> what's the time unit of espconn_regist_time()? 1 second?
in my test result, it show the unit is about 2 second. :o
both in SDK 1.4.1 and 1.5.0

Statistics: Posted by wjzhang — Fri Dec 04, 2015 3:35 pm


]]>
2015-12-02T10:32:11+08:00 2015-12-02T10:32:11+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1439&p=4858#p4858 <![CDATA[Re: the keep alive seem failed.]]>
Please update the lib LWIP as the attachment, based on ESP8266_NONOS_SDK_V1.5.0.

1. If did not call espconn_regist_time, the time out will be about 9~10s.
2. The unit of espconn_set_keepalive is 1 second, not 500 ms.

Code:

keeplive = 60; //60s
espconn_set_keepalive(pclientConnect, ESPCONN_KEEPINTVL, &keeplive);

3. You need to call espconn_set_opt to enable TCP keep alive first, then call espconn_set_keepalive to set the configuration.

Code:

uint32_t keeplive;

espconn_set_opt(pesp_conn, ESPCONN_KEEPALIVE); // enable TCP keep alive

//set keepalive: 75s = 60 + 5*3
keeplive = 60;
espconn_set_keepalive(pesp_conn, ESPCONN_KEEPIDLE, &keeplive);
keeplive = 5;
espconn_set_keepalive(pesp_conn, ESPCONN_KEEPINTVL, &keeplive);
keeplive = 3; //try times
espconn_set_keepalive(pesp_conn, ESPCONN_KEEPCNT, &keeplive);


Thanks for your interest in ESP8266 !
liblwip_nonOS_SDK_v1.5.0.zip

Statistics: Posted by ESP_Faye — Wed Dec 02, 2015 10:32 am


]]>
2015-11-30T16:20:53+08:00 2015-11-30T16:20:53+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1439&p=4821#p4821 <![CDATA[Re: the keep alive seem failed.]]> Sorry for confuse, it's 2 split issues.
1) if it not call espconn_regist_time(), it should keep TCP alive about 2 hours, why now became 20 seconds?
and why the timeout is 383s after i call espconn_regist_time(&tcpconnect, 180, 0), do you think it deviation too large?

2) do the espconn_set_keepalive() function time uint change to 1 second from 500ms?

Statistics: Posted by wjzhang — Mon Nov 30, 2015 4:20 pm


]]>
2015-11-30T08:19:17+08:00 2015-11-30T08:19:17+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1439&p=4815#p4815 <![CDATA[Re: the keep alive seem failed.]]> i want keep TCP alive about 30 minutes when TCP no data send or receive.

Statistics: Posted by wjzhang — Mon Nov 30, 2015 8:19 am


]]>
2015-11-27T12:18:05+08:00 2015-11-27T12:18:05+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1439&p=4792#p4792 <![CDATA[Re: the keep alive seem failed.]]>
Sorry that I'm confused about your question.

You mean that if the TCP connection broke, ESP8266 can know it immediately, need not to wait 30 minutes ?
Or you mean that the TCP connection does not break, but ESP8266 seems to always disconnect the TCP connection after 20s ?

Statistics: Posted by ESP_Faye — Fri Nov 27, 2015 12:18 pm


]]>
2015-11-26T18:22:15+08:00 2015-11-26T18:22:15+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1439&p=4781#p4781 <![CDATA[the keep alive seem failed.]]>

here code for set alive .
void ICACHE_FLASH_ATTR
esp_gateway_tcp_connected(void *arg)
{
uint32_t keeplive;
ESP_DBG("connected\r\n");
pclientConnect = (struct espconn *)arg;

//set keepalive: 30mins=1800s = 1500 + 10*30
keeplive = 3000; //1500s: 500ms*3000
espconn_set_keepalive(pclientConnect, ESPCONN_KEEPIDLE, &keeplive);
keeplive = 60; //again 30s: 500ms*60
espconn_set_keepalive(pclientConnect, ESPCONN_KEEPINTVL, &keeplive);
keeplive = 10; //try times
espconn_set_keepalive(pclientConnect, ESPCONN_KEEPCNT, &keeplive);
espconn_set_opt(pclientConnect, ESPCONN_KEEPALIVE);
espconn_set_opt(pclientConnect, ESPCONN_NODELAY);
espconn_set_opt(pclientConnect, ESPCONN_COPY);

//register write finish call back
tcpTxCounter = 0;
tcpTxReadIndex = 0;
tcpTxWriteIndex = 0;
tcpTxInusing = false;
espconn_regist_write_finish(pclientConnect, esp_gateway_tcp_next_send);

/*Send OnCconnected package to MCU*/
meshtalkdevice_onconnect();
//stop advise
esp_platform_advise_enable(false);
}

PC side(using javascript Nodejs v0.10) also set to
//set TCP keepalive to 30 min
remoteDevice.socket.setKeepAlive(true, 1800000);
remoteDevice.socket.setNoDelay(true);\
....

Statistics: Posted by wjzhang — Thu Nov 26, 2015 6:22 pm


]]>