From 6bc9ed08107b89e75a3df7efe5166c7c01c8b90c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 12 Oct 2025 08:27:43 -1000 Subject: [PATCH] [ota] Increase handshake timeout to 20s now that auth is non-blocking (#11186) --- esphome/components/esphome/ota/ota_esphome.cpp | 2 +- esphome/espota2.py | 2 +- tests/unit_tests/test_espota2.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/esphome/components/esphome/ota/ota_esphome.cpp b/esphome/components/esphome/ota/ota_esphome.cpp index b65bfc5ab8..569268ea15 100644 --- a/esphome/components/esphome/ota/ota_esphome.cpp +++ b/esphome/components/esphome/ota/ota_esphome.cpp @@ -29,7 +29,7 @@ namespace esphome { static const char *const TAG = "esphome.ota"; static constexpr uint16_t OTA_BLOCK_SIZE = 8192; static constexpr size_t OTA_BUFFER_SIZE = 1024; // buffer size for OTA data transfer -static constexpr uint32_t OTA_SOCKET_TIMEOUT_HANDSHAKE = 10000; // milliseconds for initial handshake +static constexpr uint32_t OTA_SOCKET_TIMEOUT_HANDSHAKE = 20000; // milliseconds for initial handshake static constexpr uint32_t OTA_SOCKET_TIMEOUT_DATA = 90000; // milliseconds for data transfer #ifdef USE_OTA_PASSWORD diff --git a/esphome/espota2.py b/esphome/espota2.py index 2712d00127..17a1da8235 100644 --- a/esphome/espota2.py +++ b/esphome/espota2.py @@ -410,7 +410,7 @@ def run_ota_impl_( af, socktype, _, _, sa = r _LOGGER.info("Connecting to %s port %s...", sa[0], sa[1]) sock = socket.socket(af, socktype) - sock.settimeout(10.0) + sock.settimeout(20.0) try: sock.connect(sa) except OSError as err: diff --git a/tests/unit_tests/test_espota2.py b/tests/unit_tests/test_espota2.py index bd1a6bde81..52c72291d6 100644 --- a/tests/unit_tests/test_espota2.py +++ b/tests/unit_tests/test_espota2.py @@ -493,7 +493,7 @@ def test_run_ota_impl_successful( assert result_host == "192.168.1.100" # Verify socket was configured correctly - mock_socket.settimeout.assert_called_with(10.0) + mock_socket.settimeout.assert_called_with(20.0) mock_socket.connect.assert_called_once_with(("192.168.1.100", 3232)) mock_socket.close.assert_called_once()