rust-libp2p icon indicating copy to clipboard operation
rust-libp2p copied to clipboard

relay: external address not removed upon listener being closed

Open dariusc93 opened this issue 3 months ago • 1 comments

Summary

When a listener tied to a relay reservation is closed, swarm doesn't emit the event indicating that the listener is closed, however the external address still persist. This happens because there is nothing in the relay client to remove the external address after the relay is closed except for when the connection itself is closed.

https://github.com/libp2p/rust-libp2p/blob/b433556e5c7466ee8c844cd38f4aea6f29ef4ea1/protocols/relay/src/priv_client.rs#L150-L155

Expected behavior

Remove external addresses after closing a listener tied to a relay

Actual behavior

Doesnt remove external addresses after closing a listener

Relevant log output


Possible Solution

When the transport closed the listener, we should also remove the external address as it would indicate that that the node is no longer reachable through the relay. Likely to be done by signaling the behaviour that the listener is closed and emit the event to remove the address.

Version

0.56

Would you like to work on fixing this bug?

Maybe

dariusc93 avatar Sep 21 '25 15:09 dariusc93

hi, it's not safe to directly expire the external address inside on_listener_closed in the relay client.

This is because there’s an existing test:

protocols/relay/tests/lib.rs → new_reservation_to_same_relay_replaces_old

that verifies the following behavior:

  • When a new reservation is established with the same relay, the old listener closes, but the external address must remain valid until the new reservation is fully accepted and active.
  • If we expire the external address immediately in on_listener_closed, this test fails because it expects the address to persist through the reservation replacement flow.

aleexeyy avatar Oct 19 '25 14:10 aleexeyy