Nonblocking slot_subscribe stuck
yipu3 opened this issue · comments
Problem
I wrote a demo program to subscribe to on-chain slot events. But the program stuck and did not receive any events from the websocket RPC (from Alchemy).
The library I use is solana_client::nonblocking::pubsub_client::PubsubClient
.
use futures_util::StreamExt;
use solana_client::nonblocking::pubsub_client::PubsubClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let ps_client = PubsubClient::new(
&"wss://solana-mainnet.g.alchemy.com/v2/xxx".to_string(),
)
.await?;
let (mut accounts, unsubscriber) = ps_client.slot_subscribe().await?;
let mut count = 0;
println!("{}", 1);
while let Some(response) = accounts.next().await {
println!("{:?}", response);
count += 1;
if count >= 5 {
break;
}
}
println!("{}", 2);
unsubscriber().await;
Ok(())
}
Is that because of the way I use the nonblocking lib?
Proposed Solution
None
This repository is no longer in use. Please re-open this issue in the agave repo: https://github.com/anza-xyz/agave