You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Packet loss issue on WS-Discovery due to event loop blocking #377
************ Add support for configurable UDP receive buffer size and async message handling to avoid packet loss on large networks **************
When running WS-Discovery on large networks with many ONVIF devices, I noticed a consistent loss of ProbeMatch messages during discovery.
After investigation, it seems the problem occurs when a large number of responses are received simultaneously.
The event loop becomes temporarily blocked due to heavy XML parsing, and incoming UDP packets overflow the system receive buffer, leading to dropped messages.
Currently:
The UDP socket uses the system’s default buffer size (around 200 KB on most Linux systems).
XML parsing is executed directly inside the 'message' event callback, which can block the event loop for a short time.
As a result, the number of discovered devices are lost and not handled
Proposed improvements
Add an option to configure the UDP receive buffer size as an option on probe function
Use setImmediate() (or similar mechanism) inside the 'message' listener to defer heavy parsing to the next event loop phase.
Activity
momoAmch commentedon Nov 13, 2025
I have PR for this issue #378
RogerHardiman commentedon Nov 13, 2025
I've merged the PR.
agsh commentedon Oct 13, 2026
@momoAmch hello!
Fixed in the v1: https://github.com/agsh/onvif/tree/master
And a lot of time ago in v0.x: https://github.com/agsh/onvif/blob/v0.x/lib/discovery.js#L101
Thank you!
fix: UDP packets loss due to event loop blocking agsh#377