-
Notifications
You must be signed in to change notification settings - Fork 23
Repeat ping request periodically #416
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
base: master
Are you sure you want to change the base?
Repeat ping request periodically #416
Conversation
src/protocol/libp2p/ping/mod.rs
Outdated
| _ = interval.tick() => { | ||
| for peer in &self.peers { | ||
| tracing::trace!(target: LOG_TARGET, ?peer, "sending ping"); | ||
| if let Err(error) = self.service.open_substream(*peer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The libp2p ping protocol spec states that the repeated pings should go on the same substream: https://github.com/libp2p/specs/blob/master/ping/ping.md
Because of this, the issue is actually more difficult due to the need to not keep the connection alive by this ping substream.
I don't think we should break the spec even if it works with the current libp2p implementation. @lexnv what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I would comply with the libp2p spec as much as possible. The main issue would be that we cannot distinguish ping susbtreams for the keep alive connection tracker 🤔
Are we entirely convinced we need to implement this for ping?
- we'll need to adjust the substream API to expose that the substream is ping (accounting towards the keepalive)
- how do we treat failures here? If we cannot open a substream should we terminate the connection? If so, we need to propagate again to the higher levels the signal to terminate the connection
- offhand, from ping we'll need to propagate towards the transport manager, and from the transport manager we'll need to propagate to individual connections
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, this is going in the right direction, but there should be a way to simplify the implementation by not introducing separate async tasks for inbound/outbound substreams and not adding command channels. It should be possible to implement polling of inbound substreams by putting them into FuturesUnordered or, may be, tokio_stream::StreamMap. The latter should be quite easy as there is maximum one inbound substream allowed from any remote peer as per ping spec: https://github.com/libp2p/specs/blob/master/ping/ping.md
|
closes #415