Socket на ESP32

Gosu

✩✩✩✩✩✩✩
27 Июн 2024
6
0
Всем привет.
Пытаюсь подключиться к сокету и отправить в него 1 бит с esp32cam при помощи незамысловатого кода:
C++:
while (s) {
    if (client.connected() || client.connect(server, SERVER_PORT)) {
        Serial.println("Connected to GS");
        client.write(1);
        client.flush();
        client.stop();
        s = false;
    } else {
        Serial.println("Error socket connect.");
    }
}
Принимается подключение на стабильном сервере и, вроде бы всё хорошо отправляется, но иногда вылазит вот такое:
Код:
Error socket connect.
Error socket connect.
[272418][E][WiFiClient.cpp:275] connect(): socket error on fd 48, errno: 113, "Software caused connection abort"
Error socket connect.
[272429][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272440][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272450][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272461][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272471][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272482][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272492][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272503][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272513][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272524][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272535][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272547][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272558][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272568][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272586][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272596][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272606][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272617][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272628][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272638][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272649][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272659][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272670][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272680][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
[272691][E][WiFiClient.cpp:249] connect(): connect on fd 48, errno: 118, "Host is unreachable"
Error socket connect.
Connected to GS
Откуда это?

Это похоже на странное поведения WI-FI модуля. Если вот эту строчку убрать то проблема исчезает:
C++:
//client.stop();