Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

client internal error: failed to hear back from WebSocket driver #1369

Open
RustMan88 opened this issue Oct 9, 2023 · 0 comments
Open

client internal error: failed to hear back from WebSocket driver #1369

RustMan88 opened this issue Oct 9, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@RustMan88
Copy link

What went wrong?

#[cfg(test)]

mod tests {
use super::*;
use tendermint_rpc::{WebSocketClient, SubscriptionClient, Client};
use tendermint_rpc::query::EventType;
use futures::StreamExt;

#[tokio::test]
async fn test_ws() {
    let (client, driver) = WebSocketClient::new("wss://rpc-osmosis.keplr.app/websocket")
    .await
    .unwrap();
let driver_handle = tokio::spawn(async move { driver.run().await });

// Standard client functionality

// let tx = format!("some-key=some-value");
// client.broadcast_tx_async(Transaction::from(tx.into_bytes())).await.unwrap();

// Subscription functionality
let mut subs = client.subscribe(EventType::NewBlock.into())
    .await
    .unwrap();

// Grab 5 NewBlock events
let mut ev_count = 5_i32;

while let Some(res) = subs.next().await {
    let ev = res.unwrap();
    println!("Got event: {:?}", ev);
    ev_count -= 1;
    if ev_count < 0 {
        break;
    }
}

// Signal to the driver to terminate.
client.close().unwrap();
// Await the driver's termination to ensure proper connection closure.
let _ = driver_handle.await.unwrap();
}

}

Steps to reproduce

Definition of "done"

@RustMan88 RustMan88 added the bug Something isn't working label Oct 9, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant