#websocket-client #ankurah #native #node #backoff #server-connection

ankurah-websocket-client

Ankurah WebSocket Client - Native WebSocket client for Ankurah

35 releases

0.7.23 Feb 17, 2026
0.7.20 Jan 30, 2026
0.7.12 Dec 30, 2025
0.7.3 Nov 26, 2025
0.5.2 Jul 29, 2025

#600 in WebSocket

MIT/Apache

1MB
15K SLoC

Ankurah WebSocket Client

A native (non-browser) WebSocket client for connecting an Ankurah node to another Ankurah node which hosts a WebSocket server

Automatic reconnection

Reconnects to the server if the connection is lost using exponential backoff

Graceful shutdown

To shutdown the client, call the shutdown method. This will wait for the connection to be closed and then return.

Basic Usage


#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Create a client node
    let storage = Arc::new(SledStorageEngine::new_test()?);
    let my_node = Node::new(storage, PermissiveAgent::new());

    // Create WebSocket client to connect to remote server (automatically starts connecting)
    let client = WebsocketClient::new(my_node.clone(), "ws://localhost:8080").await?;

    println!("State: {}", client.state().value()); // State: Connected

    // See [ankurah] for usage details

    // When you're done, shutdown the client
    client.shutdown().await?;
    Ok(())
}

// See ankurah for basic details

Dependencies

~18–29MB
~468K SLoC