Skip to content

fix: P2P Stream timeout for battery cameras relying on STREAM_TIMEOUT_SECONDS#1451

Merged
fuatakgun merged 1 commit intofuatakgun:masterfrom
abhiravk:fix-battery-camera-streams
Apr 8, 2026
Merged

fix: P2P Stream timeout for battery cameras relying on STREAM_TIMEOUT_SECONDS#1451
fuatakgun merged 1 commit intofuatakgun:masterfrom
abhiravk:fix-battery-camera-streams

Conversation

@abhiravk
Copy link
Copy Markdown
Contributor

@abhiravk abhiravk commented Apr 8, 2026

Description

Currently, battery-powered doorbells inherently take 3-10 seconds to wake up from deep sleep and negotiate a connection. While a global STREAM_TIMEOUT_SECONDS of 15s is defined in const.py, both camera.py and p2p_streamer.py use arbitrarily hardcoded timeouts (5s and 1s respectively). This causes streams to drop with LivestreamNotRunningError on battery cameras.

This PR replaces the hardcoded asyncio.wait_for(..., 5) with the existing STREAM_TIMEOUT_SECONDS, and calculates the streamer retry limit dynamically based on this config.

@abhiravk abhiravk changed the title Fix P2P Stream timeout for battery cameras relying on STREAM_TIMEOUT_SECONDS fix: P2P Stream timeout for battery cameras relying on STREAM_TIMEOUT_SECONDS Apr 8, 2026
@fuatakgun
Copy link
Copy Markdown
Owner

Thanks for the PR. Can you post your test results too?

@fuatakgun fuatakgun merged commit cb2bcb2 into fuatakgun:master Apr 8, 2026
4 of 5 checks passed
@fuatakgun
Copy link
Copy Markdown
Owner

No no, it was already merged. I was just curious, thanks again

@abhiravk
Copy link
Copy Markdown
Contributor Author

abhiravk commented Apr 9, 2026

Thanks for merging.

In go2rtc v1.9.0+, I needed this fix also to make my Eufy camera work.
Without this, go2rtc 1.9.0+ versions throw a 400 Bad Request streams: source not supported error, blocking the dynamically created byte ingest flow completely because it violently rejects unknown schemas).

diff --git a/custom_components/eufy_security/eufy_security_api/p2p_streamer.py b/custom_components/eufy_security/eufy_security_api/p2p_streamer.py
index df1a65a..7ec4906 100644
--- a/custom_components/eufy_security/eufy_security_api/p2p_streamer.py
+++ b/custom_components/eufy_security/eufy_security_api/p2p_streamer.py
@@ -73,7 +73,7 @@ async def _create_stream_on_go2rtc(self):
                 result = response.status, await response.text()
                 _LOGGER.debug(f"create_stream_on_go2rtc - delete stream response {result}")
 
-        parameters = {"name": str(self.camera.serial_no), "src": str(self.camera.serial_no)}
+        parameters = {"name": str(self.camera.serial_no), "src": "tcp://127.0.0.1:65535"}
         url = GO2RTC_API_URL.format(self.camera.config.rtsp_server_address, GO2RTC_API_PORT)
         url = f"{url}s"
         async with aiohttp.ClientSession() as session:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants