From 16292c981eb0f03be6285d4946614a574f204af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Villac=C3=ADs=20Lasso?= Date: Mon, 2 Aug 2021 16:47:07 -0500 Subject: [PATCH] Update RX timestamp right after assigning socket Otherwise the socket poll callback races with the RX timeout (if nonzero) and will immediately disconnect the socket without waiting for it to actually finish connecting. --- src/AsyncTCP.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/AsyncTCP.cpp b/src/AsyncTCP.cpp index a44ebd5..2d712e1 100644 --- a/src/AsyncTCP.cpp +++ b/src/AsyncTCP.cpp @@ -496,6 +496,7 @@ bool AsyncClient::connect(IPAddress ip, uint16_t port) xSemaphoreTakeRecursive(_asyncsock_mutex, (TickType_t)portMAX_DELAY); _conn_state = 2; _socket = sockfd; + _rx_last_packet = millis(); xSemaphoreGiveRecursive(_asyncsock_mutex); // Socket is now connecting. Should become writable in asyncTcpSock task