Skip to content

Conversation

@bdraco
Copy link
Member

@bdraco bdraco commented Dec 14, 2025

What does this implement/fix?

Increases the OTA client-side socket timeout from 30 seconds to 90 seconds to match the device-side OTA_SOCKET_TIMEOUT_DATA.

When the timeouts don't match, the client can give up waiting for chunk acknowledgments before the device has actually failed. This is particularly problematic on slower platforms like LibreTiny/Beken where flash writes can take longer. The premature timeout causes:

  1. Client disconnects mid-transfer
  2. Device OTA state is left in a bad state
  3. Subsequent OTA attempts fail with "Begin error: 0" until device reboots

By matching the timeouts, actual failures are detected via proper error responses rather than timeouts.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Developer breaking change (an API change that could break external components)
  • Code quality improvements to existing code or addition of tests
  • Other

Related issue or feature (if applicable):

  • N/A

Pull request in esphome-docs with documentation (if applicable):

  • N/A

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040
  • BK72xx
  • RTL87xx
  • nRF52840

Example entry for config.yaml:

# No config changes needed - this fixes OTA reliability

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@bdraco bdraco added this to the 2025.12.0b3 milestone Dec 14, 2025
Copilot AI review requested due to automatic review settings December 14, 2025 18:35
@bdraco bdraco requested a review from a team as a code owner December 14, 2025 18:35
@codecov-commenter
Copy link

codecov-commenter commented Dec 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.60%. Comparing base (cfc0d8b) to head (7eff321).
⚠️ Report is 21 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev   #12484   +/-   ##
=======================================
  Coverage   72.60%   72.60%           
=======================================
  Files          53       53           
  Lines       11192    11192           
  Branches     1517     1517           
=======================================
  Hits         8126     8126           
  Misses       2674     2674           
  Partials      392      392           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR increases the OTA client socket timeout from 30 seconds to 90 seconds to match the device-side OTA_SOCKET_TIMEOUT_DATA constant. This synchronization prevents premature client disconnects during OTA updates, especially on slower platforms like LibreTiny/Beken where flash write operations take longer. When timeouts are mismatched, the client can give up before the device detects an actual failure, leaving the device OTA state corrupted.

Key Changes

  • Updated socket timeout from 30s to 90s in the data transfer phase
  • Added clarifying comment referencing the device-side constant
  • Maintains existing 20s timeout for the initial connection/handshake phase

@bdraco
Copy link
Member Author

bdraco commented Dec 14, 2025

thanks

@bdraco bdraco merged commit 8524b89 into dev Dec 14, 2025
40 checks passed
@bdraco bdraco deleted the ota_timeout_fix branch December 14, 2025 19:47
@swoboda1337 swoboda1337 mentioned this pull request Dec 14, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Dec 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants