Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions libp2p/src/tutorials/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,12 @@
//! ## Idle connection timeout
//!
//! Now, for this example in particular, we need set the idle connection timeout.
//! Otherwise, the connection will be closed immediately.
//! The default connection timeout is 10 seconds.
//!
//! Whether you need to set this in your application too depends on your usecase.
//! Typically, connections are kept alive if they are "in use" by a certain protocol.
//! The ping protocol however is only an "auxiliary" kind of protocol.
//! Thus, without any other behaviour in place, we would not be able to observe the pings.
//! Thus, without any other behaviour in place, we would not be able to observe any pings after 10s.
//!
//! ```rust
//! use std::{error::Error, time::Duration};
Expand All @@ -232,6 +232,9 @@
//! yamux::Config::default,
//! )?
//! .with_behaviour(|_| ping::Behaviour::default())?
//! .with_swarm_config(|cfg| {
//! cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))
//! }) // Allows us to observe pings indefinitely.
//! .build();
//!
//! Ok(())
Expand Down Expand Up @@ -284,6 +287,9 @@
//! yamux::Config::default,
//! )?
//! .with_behaviour(|_| ping::Behaviour::default())?
//! .with_swarm_config(|cfg| {
//! cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))
//! }) // Allows us to observe pings indefinitely.
//! .build();
//!
//! // Tell the swarm to listen on all interfaces and a random, OS-assigned
Expand Down Expand Up @@ -329,6 +335,9 @@
//! yamux::Config::default,
//! )?
//! .with_behaviour(|_| ping::Behaviour::default())?
//! .with_swarm_config(|cfg| {
//! cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))
//! }) // Allows us to observe pings indefinitely.
//! .build();
//!
//! // Tell the swarm to listen on all interfaces and a random, OS-assigned
Expand Down
Loading