Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
LVivona authored Mar 1, 2025
2 parents 172025e + 37aa175 commit a85c915
Showing 1 changed file with 11 additions and 2 deletions.
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

0 comments on commit a85c915

Please sign in to comment.