rust-web3
rust-web3 copied to clipboard
Web3 blocks with low count of tokio threads
Web3 runs fine with the following tokio settings: #[tokio::main] but it blocks indefinitely with
#[tokio::main(max_threads = 4)] or #[tokio::main(core_threads = 40, max_threads = 40)]
@bkolad any particular transport?
@tomusdrw it is web3::transports::Http
Would you mind testing with Ws as well? I checked the code but there is nothing fancy we do that would cause such behaviour and I feel tempted to blame hyper.
I confirm it works with Ws, thx.
I'm getting this same error with both http and ws transports. The code blocks indefinitely when trying to get the current block number.
Here's a small code that reproduces this error:
use tokio;
// #[tokio::main] // works
#[tokio::main(max_threads=4)] // fails
async fn main() {
let transport = web3::transports::Http::new("http://localhost:8545").unwrap();
// let transport = web3::transports::WebSocket::new("ws://localhost:8546")
// .await
// .unwrap();
let chain = web3::Web3::new(transport);
let block_number = chain.eth().block_number().await.unwrap();
println!("{}", block_number);
}
Tested on web3 0.14 and 0.15 and tokio 0.2.25.