Json-RPC example in Rust by using https://github.com/paritytech/jsonrpc
This repo try to use tokio = 0.2
with jsonrpc-tcp-server = 14.2
which use futures = 0.1
.
There is a TCP client beside the example crate to demonstrate the jsonrpc interaction.
I try to implement the async Rpc response with async
--> std::future::Future
. But it stuck at the await
in the async
block.
let resp_fut = async move {
match rx.recv().await {
// Block at here
Some(id) => Ok(id),
None => Err(types::Error::new(types::ErrorCode::InternalError)),
}
};
I thought it's the same compatibility problem between tokio = 0.2
and futures = 0.1
, BUT if I change the transport to jsonrpc-http-sever
(feature in the example/Cargo.toml
), it works fine.
The screen shot picture shows the subsequent requests will not be processed until the preceding async finished.