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

[BUG] Crashing on requests happening too fast #109

Open
PaulDotSH opened this issue Aug 1, 2023 · 6 comments
Open

[BUG] Crashing on requests happening too fast #109

PaulDotSH opened this issue Aug 1, 2023 · 6 comments

Comments

@PaulDotSH
Copy link

With the sample code

    let mut client = RpcClientBuilder::new()
        .build("http://127.0.0.1:38085")
        .unwrap();
    let mut wallet = client.wallet();
    println!("{:?}", wallet.open_wallet("test-wallet".to_string(), Some("test141414A".to_string())).await);
    
    let foo = wallet.get_balance(0, None).await;
    println!("{:?}", foo);

The following program crashes, with the error

Err(error sending request for url (http://127.0.0.1:38085/json_rpc): connection closed before message completed

Caused by:
connection closed before message completed)

However, adding a sleep between the open_wallet and get_balance requests makes it work as intended.

@PaulDotSH
Copy link
Author

New info, this happens with any requests that are happening "too fast"

    println!("{:?}", daemon.get_block_count().await);
    println!("{:?}", daemon.get_block_count().await);
    println!("{:?}", daemon.get_block_count().await);
    println!("{:?}", daemon.get_block_count().await);
    println!("{:?}", daemon.get_block_count().await);

Has the same behavior

@PaulDotSH
Copy link
Author

Adding std::thread::sleep(std::time::Duration::from_nanos(1)); on json_rpc_call before the request is made solves this, however it is not something that should be done...

@PaulDotSH
Copy link
Author

@vorot93 @h4sh3d

@PaulDotSH
Copy link
Author

Also, if you dont have this problem try running your blockchain locally and using --release

@mvntainer
Copy link

I also faced this issue, any plans to fix?

@h4sh3d
Copy link
Member

h4sh3d commented Sep 15, 2023

I suspect the problem is on the node/wallet side and not from the crate. Did you try to query at the same pace the node with another lib or with curl directly to see if the problem still exists?

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

No branches or pull requests

3 participants