-
Notifications
You must be signed in to change notification settings - Fork 231
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
HTTP client should not try to parse body of response with non-2XX status code #1359
Comments
If you add tracing-subscriber = { version = "0.3.17", features = ["env-filter", "fmt"] } and install it within #[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
// ... snip ...
} and then run the executable with
then the HTTP client will output the outgoing requests it makes and their corresponding incoming responses:
On the second to last line, we see that the server responded with a plain text message that Therefore, the issue lies with the server which appears to be doing rate limiting/throttling. To solve this, you will have to use the machinery provided by Tokio to ensure you don't perform too many requests at once, or just not try to perform concurrent requests. There is nothing the HTTP client can do for you by default. Hope that helps! |
I did a quick test, and by adding a (fairly hefty) delay the node will reliably answer both queries: let r_task = async {
tokio::time::sleep(tokio::time::Duration::from_millis(750)).await;
c.tx_search(query, false, 1, 12, tendermint_rpc::Order::Descending)
.await
}; |
Thanks for founding this. I was probably tired because I did Overall I think this should be handled better by On stackoverflow I found links how json-rpc should be handled when transport layer is http: https://www.simple-is-better.org/json-rpc/transport_http.html JSON-RPC 2.0 is sent over HTTP so if HTTP return error then the body shouldn't be parsed but error should be returned. |
That's a good point! Let me re-open the issue then. |
What went wrong?
Concurrent request to
tx_search
fails withvalue: serde parse error
Steps to reproduce
Cargo.toml
main.rs (not working)
main.rs(working)
diff between `not working` and `working` implementation:
Definition of "done"
concurrent calls to
HttpClient
should working without any side effectsThe text was updated successfully, but these errors were encountered: