Skip to content

Conversation

@rmaher001
Copy link
Contributor

Summary

Fixes event stream disconnections by implementing heartbeat monitoring to detect camera restarts and network issues.

Changes

  • Implement 15-second heartbeat monitoring with asyncio.wait_for() to detect missed heartbeats
  • Reconnect automatically when camera stops sending heartbeats (camera restarts, network issues)
  • Add 1-hour timeout as fallback (was using 5-minute default that caused frequent disconnections)

Testing

Tested for 38+ hours:

  • Camera events continue working after camera restarts (3 restarts tested, all detected and recovered within 15 seconds)
  • No missed events during entire test period
  • Fallback 1-hour timeout working as safety net

Fixes issues where camera events would stop working after camera restarts or disconnect every 5 minutes due to default timeout.

@rmaher001 rmaher001 force-pushed the feature/heartbeat-monitoring branch 2 times, most recently from 4a0f84d to 7f7597b Compare October 22, 2025 15:03
Set 1-hour timeout instead of default 5-minute timeout on event stream request. Implement 15-second heartbeat monitoring with asyncio.wait_for() to detect and recover from camera restarts and network issues.
@rmaher001 rmaher001 force-pushed the feature/heartbeat-monitoring branch from 7f7597b to 7e68cd4 Compare October 22, 2025 15:08
ndrwstn pushed a commit to ndrwstn/hacs-dahua that referenced this pull request Nov 29, 2025
Apply PR rroller#519 from rroller/dahua (by rmaher001).

- Add 1-hour timeout to event stream request
- Implement 15-second heartbeat monitoring to detect camera disconnects
- Re-raise TimeoutError to trigger automatic reconnection

Tested 38+ hours with camera restarts in original PR.
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.

1 participant