Skip to content
2 changes: 2 additions & 0 deletions examples/browser-webrtc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ It uses [wasm-pack](https://rustwasm.github.io/docs/wasm-pack/) to build the pro

## Running the example

Ensure you have `wasm-pack` [installed](https://rustwasm.github.io/wasm-pack/).

1. Build the client library:
```shell
wasm-pack build --target web --out-dir static
Expand Down
4 changes: 3 additions & 1 deletion examples/browser-webrtc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ pub async fn run(libp2p_endpoint: String) -> Result<(), JsError> {
webrtc_websys::Transport::new(webrtc_websys::Config::new(&key))
})?
.with_behaviour(|_| ping::Behaviour::new(ping::Config::new()))?
.with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(5)))
// Ping does not KeepAlive, so we set the idle connection timeout to 32_212_254u64,
Comment thread
thomaseizinger marked this conversation as resolved.
Outdated
// which is the largest value that works with the wasm32 target.
.with_swarm_config(|c| c.with_idle_connection_timeout(Duration::from_secs(32_212_254u64)))
.build();

let addr = libp2p_endpoint.parse::<Multiaddr>()?;
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-webrtc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async fn main() -> anyhow::Result<()> {
.with_behaviour(|_| ping::Behaviour::default())?
.with_swarm_config(|cfg| {
cfg.with_idle_connection_timeout(
Duration::from_secs(30), // Allows us to observe the pings.
Comment thread
thomaseizinger marked this conversation as resolved.
Duration::from_secs(u64::MAX), // Allows us to observe the pings.
)
})
.build();
Expand Down