- [812835][D][WiFiClient.cpp:545] connected(): Disconnected: RES: 0, ERR: 128
I am using WiFiClient to connect my ESP32 to a TCP server on my computer. Everything works nice until the server (PC) closes the connection.
When the server closes the connection, the function that returns the connection status waits exactly 100s before returning the connection status
When debugging in the terminal, you can see exactly when the server closed the connection. In terminal I see line like below
My code below
- .....
- //Connecting to server
- while(!RemoteClient.connect(server_host, server_port))
- {
- Serial.println("Waiting beafore connect");
- delay(2500);
- ledState = !ledState;
- digitalWrite(LED_GREEN_PIN, ledState);
- Serial.print("Connecting to ");
- Serial.println(server_host);
- }
- ......
- void loop() {
- if (RemoteClient.connected()) //<---- Here the program stops for 100s after the server breaks communication
- {
- ....
- }
- else
- {
- sleep(100);
- Serial.println("No connction with server. Reconnect");
- Serial.print(".");
- RemoteClient.stop();
- ConnectToServer();
- }
- }
- 18:27:35.591 -> [812835][D][WiFiClient.cpp:545] connected(): Disconnected: RES: 0, ERR: 128
- 18:29:15.593 -> No connction with server. Reconnect
- 18:29:15.593 -> .Connecting to server
- 18:29:38.255 -> [935514][D][WiFiClient.cpp:545] connected(): Disconnected: RES: 0, ERR: 128
- 18:31:18.272 -> No connction with server. Reconnect
- 18:31:18.272 -> .Connecting to server