fix(relay): wait for channel binding in smoke test script (#1853)

`webrtc-rs` has a race condition where `send_to` does not actually await
the channel binding, thus attempting to send something through the
channel from the other end my fail because we receive the bytes from the
relay before the library registers that there is an active channel.

This should hopefully fix the flakiness of the smoke test script.
This commit is contained in:
Thomas Eizinger
2023-08-04 05:17:20 +02:00
committed by GitHub
parent 4a72e33378
commit a552e695f7

View File

@@ -2,6 +2,7 @@ use anyhow::Result;
use redis::AsyncCommands;
use std::net::SocketAddr;
use std::sync::Arc;
use std::time::Duration;
use tokio::net::UdpSocket;
use webrtc::turn::client::*;
use webrtc::turn::Error;
@@ -33,6 +34,10 @@ async fn main() -> Result<()> {
// Instead, it will implicitly create one when trying to send data to a remote.
relay_conn.send_to(b"HOLEPUNCH", gateway_addr).await?;
// `webrtc-ts` does not block on the creation of the channel binding.
// Wait for some amount of time here to avoid race conditions.
tokio::time::sleep(Duration::from_millis(10)).await;
println!("Created channel to gateway");
// Now that our relay connection is active, share the address with the gateway.