LWIP connect/write/read stuck

btomic
Posts: 5
Joined: Thu May 04, 2017 7:01 pm

LWIP connect/write/read stuck

Postby btomic » Mon Feb 11, 2019 1:50 am

Hello,

I am using ESP8266_RTOS_SDK_v2.x.x LWIP library to connect to a remote server. I have a client task which calls a function to send some data to the server. The function is basically identical to the local_ota_begin() function which can be found in ota_demo example. It creates a socket, then calls 'connect', 'write', 'read' and eventually 'close'. The only difference from ota_demo is that before creating a socket it calls netconn_gethostbyname().

The task is in the 30-second loop which means the function is called twice in a minute. The task runs perfectly for several days and then it gets stuck. I see it because after each loop I blink the blue LED for 500 ms and I see that it blinks every 30 seconds for several days before it stops blinking.

However, If I power-down my router the task gets unstuck immediately! I can see that because I set a flag in the wifi_set_event_handler_cb function when the connection is lost and I test this flag at the beginning of the task loop. If the flag is set it makes the blue LED blink fast (100ms ON/OFF) for 10 times and it really blinks like that for as long as the router is powered down. This means that the task is unstuck by the loss of the wifi connection!

When I power-up the router I see that the LED stops fast blinking and starts blinking slowly for 500 ms once in 30 seconds (of course it first blinks every few seconds until the vTaskDelayUntil catches up with its time). I also see that the messages to the server go through again. It works fine again for several days until it gets stuck again.

One of the messages that go to the server is a heap size and I can see that it is stable and unchanged.

Does anyone know what is happening in LWIP, where it might get blocked and how to fix this?

Thanks

Who is online

Users browsing this forum: No registered users and 10 guests