Skip to content

Add autoreconnect to network clients#433

Merged
S-Dafarra merged 4 commits into
masterfrom
client-auto-reconnect
Jun 4, 2026
Merged

Add autoreconnect to network clients#433
S-Dafarra merged 4 commits into
masterfrom
client-auto-reconnect

Conversation

@RiccardoGrieco
Copy link
Copy Markdown
Contributor

This pull request adds automatic reconnection logic for their input ports if the connection to the expected data source is lost.

This allows e.g. the HumanStateVisualizer to keep running while the other modules restart

Key changes include:

Automatic reconnection and port monitoring:

  • Each client (HumanDynamics_nwc_yarp, HumanState_nwc_yarp, HumanWrench_nwc_yarp, WearableTargets_nwc_yarp) now checks in its run() method whether its input port is disconnected. If so, it logs a warning (throttled to once every 5 seconds) and attempts to reconnect to the configured data port. This makes the clients more resilient to temporary network issues.

cc @camillagallina2000

@S-Dafarra
Copy link
Copy Markdown
Contributor

Consider that even if the network drops, when it is available again, the communication should restart without issues, provided that the sockets did not close.

This is useful in case the server is restarted. Nonetheless, I would avoid doing this connections automatically. I would suggest to use a RPC instead. The reasons are:

Hence, if the reconnection is done "manually", you can avoid both issues.

Another possibility would be to enable this mechanism only via optional configuration parameter

Copy link
Copy Markdown
Contributor

@traversaro traversaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok for me once @S-Dafarra is happy.

@RiccardoGrieco
Copy link
Copy Markdown
Contributor Author

@S-Dafarra I switched to using yarp's PortReport to check for disconnections. Also I made the reconnection enabled by a configuration parameter

Copy link
Copy Markdown
Contributor

@S-Dafarra S-Dafarra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks

@S-Dafarra S-Dafarra merged commit bee02ac into master Jun 4, 2026
6 checks passed
@camillagallina2000 camillagallina2000 deleted the client-auto-reconnect branch June 5, 2026 13:21
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.

3 participants