From f2886c33ad6c45f600f0ff687598fcf5e3383a94 Mon Sep 17 00:00:00 2001 From: shamardy Date: Thu, 21 Sep 2023 22:09:22 +0300 Subject: [PATCH 1/2] reduce web3 request timeout to 20s --- mm2src/coins/eth/web3_transport/http_transport.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm2src/coins/eth/web3_transport/http_transport.rs b/mm2src/coins/eth/web3_transport/http_transport.rs index 5272974310..f58f367559 100644 --- a/mm2src/coins/eth/web3_transport/http_transport.rs +++ b/mm2src/coins/eth/web3_transport/http_transport.rs @@ -183,7 +183,7 @@ async fn send_request( use http::header::HeaderValue; use mm2_net::transport::slurp_req; - const REQUEST_TIMEOUT_S: f64 = 60.; + const REQUEST_TIMEOUT_S: f64 = 20.; let mut errors = Vec::new(); From 57c29631412763697b29eaad297ae6f633efb689 Mon Sep 17 00:00:00 2001 From: shamardy Date: Mon, 25 Sep 2023 19:59:52 +0300 Subject: [PATCH 2/2] add method and id to the timeout log --- mm2src/coins/eth/web3_transport/http_transport.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mm2src/coins/eth/web3_transport/http_transport.rs b/mm2src/coins/eth/web3_transport/http_transport.rs index f58f367559..02822ebe5d 100644 --- a/mm2src/coins/eth/web3_transport/http_transport.rs +++ b/mm2src/coins/eth/web3_transport/http_transport.rs @@ -3,7 +3,7 @@ use crate::eth::{web3_transport::Web3SendOut, EthCoin, GuiAuthMessages, RpcTrans use common::APPLICATION_JSON; use futures::lock::Mutex as AsyncMutex; use http::header::CONTENT_TYPE; -use jsonrpc_core::{Call, Response}; +use jsonrpc_core::{Call, Id, Response}; use mm2_net::transport::{GuiAuthValidation, GuiAuthValidationGenerator}; use serde_json::Value as Json; #[cfg(not(target_arch = "wasm32"))] use std::ops::Deref; @@ -215,9 +215,14 @@ async fn send_request( let res = match rc { Either::Left((r, _t)) => r, Either::Right((_t, _r)) => { + let (method, id) = match &request { + Call::MethodCall(m) => (m.method.clone(), m.id.clone()), + Call::Notification(n) => (n.method.clone(), Id::Null), + Call::Invalid { id } => ("Invalid call".to_string(), id.clone()), + }; let error = format!( - "Error requesting '{}': {}s timeout expired", - node.uri, REQUEST_TIMEOUT_S + "Error requesting '{}': {}s timeout expired, method: '{}', id: {:?}", + node.uri, REQUEST_TIMEOUT_S, method, id ); warn!("{}", error); errors.push(Web3RpcError::Transport(error));