Skip to content

WiFi client hangs on reconnect/wifi lost #231

Closed
@Toshik

Description

@Toshik

If ESP tries to send something over WiFi while WiFi network suddenly switches of, there is 99% chance to hang ESP.
I use following code to debug with Socket Test Tool (http://sourceforge.net/projects/sockettest/):

void loop() {
    delay(10);

    if (WiFi.status() == WL_CONNECTED)
    {
        Serial.print("test wf: ");
        Serial.println(counter++);
        int connected = wifiClient.connected();
        if (connected)
        {
            Serial.println("test wf: sending");
            wifiClient.write("0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\r\n", 132);
            wifiClient.flush();
            Serial.println("test wf: sent");
        }
        else
        {
            Serial.println("test wf: connecting");
            wifiClient.connect(SOCKET_SERVER_IP_ADDRESS, 21);
        }

        Serial.println("test wf: done");
    }
}

I got following output:

test wf: 240
test wf: sending
test wf: sent
test wf: done
test wf: 241
test wf: sending
beacon timeout
rm match
pm close 7 0 0/21552041

 ets Jan  8 2013,rst cause:4, boot mode:(1,6)

wdt reset

After that ESP can be reset only by hardware button.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions