diff --git a/esphome/components/api/api_frame_helper.cpp b/esphome/components/api/api_frame_helper.cpp index 73efc55824..82ebd531f6 100644 --- a/esphome/components/api/api_frame_helper.cpp +++ b/esphome/components/api/api_frame_helper.cpp @@ -283,7 +283,10 @@ APIError APINoiseFrameHelper::loop() { return err; if (this->tx_buf_.empty()) return APIError::OK; - return try_send_tx_buf_(); + err = try_send_tx_buf_(); + if (err == APIError::WOULD_BLOCK) + return APIError::OK; // Convert WOULD_BLOCK to OK to avoid connection termination + return err; } /** Read a packet into the rx_buf_. If successful, stores frame data in the frame parameter @@ -802,7 +805,10 @@ APIError APIPlaintextFrameHelper::loop() { } if (this->tx_buf_.empty()) return APIError::OK; - return try_send_tx_buf_(); + APIError err = try_send_tx_buf_(); + if (err == APIError::WOULD_BLOCK) + return APIError::OK; // Convert WOULD_BLOCK to OK to avoid connection termination + return err; } /** Read a packet into the rx_buf_. If successful, stores frame data in the frame parameter