Skip to content

Packet loss issue on WS-Discovery due to event loop blocking #377

Closed

Description

@momoAmch

************ 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.
  • Other options can be done using thread works also

Activity

  1. momoAmch commented on Nov 13, 2025

    @momoAmch
    ContributorAuthor

    I have PR for this issue #378

  2. RogerHardiman commented on Nov 13, 2025

    @RogerHardiman
    Collaborator

    I've merged the PR.

  3. agsh commented on Oct 13, 2026

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions