retry_connect

Function retry_connect 

Source
pub async fn retry_connect<S: AsRef<str>>(
    uri: S,
    retry_delay: Duration,
    retries_count: usize,
) -> Result<(Client, EventStream), WsError>
Expand description

Like connect but retries to connect retries_count times before returning an error. This method is needed when you run simplex-cli programmatically and don’t know when WebSocket port becomes available.

let port = 5225;
let cli = SimplexCli::spawn(port);
let uri = format!("ws://127.0.0.1:{port}");

let (client, mut events) = simploxide_client::retry_connect(&uri, Duration::from_secs(1), 10).await?;

//...