Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years ago.
Websocket loss of connection causes hang?
My program uses wifi and websockets, if internet connection is lost then the program freezes (or crashes with watchdog). Here is simplified code:
void main() { while(true) { //OTHER STUFF if(ws.is_connected() == true) { led2 = 1; sprintf(wstemp, "%f*%f*%f*%f", temp, trip_level, hyst_amount, wscontrol); ws.send(wstemp); if(ws.read(ws_recv)) { string check = ws_recv; { char *wdi; wdi = strtok(ws_recv,"*"); trip_level = atof(wdi); while(wdi != NULL) { hyst_amount = atof(wdi); wdi = strtok (NULL, "*"); } } } led2 = 0; } } }
Using a oscilloscope I can see the program spends a lot of time in the websocket.is_connected loop.