Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

PubsubClient: Unable to use .next() after logs_subscribe subscription initialized #35528

Closed
bologer opened this issue Apr 23, 2024 · 1 comment
Labels
community Community contribution

Comments

@bologer
Copy link

bologer commented Apr 23, 2024

Problem

I'm using PubsubClient to subscribe to new logs using logs_subscribe.
However, when I run this code, it ends up wit the following error:

error[E0599]: no method named `next` found for struct `Pin<Box<dyn futures_core::stream::Stream<Item = solana_client::rpc_response::Response<RpcLogsResponse>> + Send>>` in the current scope
  --> src/main.rs:90:27
   |
90 |         let logs = stream.next().await.unwrap();
   |                           ^^^^ method not found in `Pin<Box<dyn Stream<Item = Response<RpcLogsResponse>> + Send>>`
   |
   = help: items from traits can only be used if the trait is in scope
help: the following traits are implemented but not in scope; perhaps add a `use` for one of them:
   |
1  + use enum_iterator::Sequence;
   |
1  + use futures_util::stream::stream::StreamExt;
   |
1  + use serde_json::de::Read;
   |
1  + use std::iter::Iterator;
   |
     and 2 other candidates

Here is minimal code:

// ...
use solana_client::nonblocking::pubsub_client::PubsubClient;
use solana_client::rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig, RpcTransactionLogsConfig, RpcTransactionLogsFilter};

#[tokio::main]
async fn main() {
    let ws_client: PubsubClient = PubsubClient::new(&config.rpc_ws).await.unwrap();

    let (mut stream, _) = ws_client
        .logs_subscribe(
            RpcTransactionLogsFilter::All,
            RpcTransactionLogsConfig {
                commitment: Some(CommitmentConfig::processed()),
            },
        )
        .await?;

    loop {
        let logs = stream.next().await.unwrap();
        println!("logs: {:?}", logs);
    }
}

The issue is happening also when using any other subscription methods, such as program_subscribe.

More debug info:

$ rustc --version
rustc 1.77.2 (25ef9e3d8 2024-04-09)

Cargo.toml:

[dependencies]
solana-client = "1.18.11"

Any idea why this could be happening?

Proposed Solution

@bologer bologer added the community Community contribution label Apr 23, 2024
Copy link
Contributor

This repository is no longer in use. Please re-open this issue in the agave repo: https://github.com/anza-xyz/agave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution
Projects
None yet
Development

No branches or pull requests

1 participant