-
Notifications
You must be signed in to change notification settings - Fork 109
Fix event stream 5-minute timeout disconnections #501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The Dahua integration was setting heartbeat=5 in the event subscription URL but never actually sending keepalive messages, causing the connection to timeout after ~300 seconds (5 minutes). This fix: - Creates an async task that sends keepalive requests every 5 seconds - Uses a lightweight API endpoint for keepalive messages - Properly cleans up the keepalive task when the connection closes - Prevents the camera from timing out the event stream Tested with actual Dahua camera - connection remains stable beyond 5 minutes.
…connections The Dahua event stream was disconnecting every 5 minutes due to aiohttp's default total timeout of 300 seconds. Since the event stream is meant to run indefinitely, this timeout should be disabled. This fix adds ClientTimeout(total=None) to the event stream request, allowing it to maintain persistent connection for IVS events monitoring. Tested for 50+ minutes with no disconnections. Fixes issue where important IVS events could be missed during reconnection.
943fd5e to
f570e3d
Compare
Owner
|
Thank you! |
rmaher001
added a commit
to rmaher001/dahua
that referenced
this pull request
Oct 5, 2025
The previous fix (rroller#501) applied the timeout at the request level in client.py. This applies the same fix at the session level in __init__.py, which is more appropriate as the session is created specifically for the Dahua client. - Set timeout=ClientTimeout(total=None) on ClientSession creation - Validated in production with no timeouts
rmaher001
added a commit
to rmaher001/dahua
that referenced
this pull request
Oct 5, 2025
Moves timeout fix from request level (rroller#501) to session level, which is more appropriate since the session is created specifically for the Dahua client. Changes: - Add timeout=ClientTimeout(total=None) to ClientSession creation in __init__.py - Revert request-level timeout fix from client.py The session-level fix prevents the default 5-minute timeout from disconnecting infinite event streams while keeping regular API requests properly scoped. Tested in production with no timeout errors.
Contributor
Author
|
You are welcome. It looks like it was not sufficient. I sent you a new one
<#508> where it is applied at the
session level instead.
…On Fri, Oct 3, 2025 at 8:02 AM Ronnie ***@***.***> wrote:
*rroller* left a comment (rroller/dahua#501)
<#501 (comment)>
Thank you!
—
Reply to this email directly, view it on GitHub
<#501 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMYHVDMQC22DDN64NYFJZO33V2FXVAVCNFSM6AAAAACIFLCP5KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGNRWGA3TQNJSGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
rroller
pushed a commit
that referenced
this pull request
Oct 6, 2025
Moves timeout fix from request level (#501) to session level, which is more appropriate since the session is created specifically for the Dahua client. Changes: - Add timeout=ClientTimeout(total=None) to ClientSession creation in __init__.py - Revert request-level timeout fix from client.py The session-level fix prevents the default 5-minute timeout from disconnecting infinite event streams while keeping regular API requests properly scoped. Tested in production with no timeout errors.
Owner
|
Had to revert this, users are reporting issues |
Contributor
Author
|
Hi Ronnie,
Thanks for the update. It's understandable that users are reporting issues,
as the scenario with the disconnect/reboot was not taken into consideration.
I'm currently testing another fix that relies on the heartbeat mechanism. I
will send you a new pull request shortly for your review.
Best,
Richard
…On Thu, Oct 9, 2025 at 8:41 PM Ronnie ***@***.***> wrote:
*rroller* left a comment (rroller/dahua#501)
<#501 (comment)>
Had to revert this, users are reporting issues
—
Reply to this email directly, view it on GitHub
<#501 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMYHVDPINNKHHDDUNIVUWHD3W4TF3AVCNFSM6AAAAACIFLCP5KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGOBYGE3TQNZSGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
The event stream disconnects every 5 minutes, causing the integration to miss important IVS events during reconnection.
What
ClientTimeout(total=None)on the event stream request to disable aiohttp's default 300-second timeout