Skip to content

Commit

Permalink
Merge pull request #10 from MutinyWallet/ping-timeout
Browse files Browse the repository at this point in the history
Fix ping timeout inconsistant number
  • Loading branch information
TonyGiorgio authored May 13, 2023
2 parents 6970fb0 + 66d31fe commit eeba5e5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use tokio::{
use tower_http::trace::{DefaultMakeSpan, TraceLayer};

const PUBKEY_BYTES_LEN: usize = 33;
const PING_TIMEOUT: u64 = 11;

pub(crate) type WSMap =
Arc<Mutex<HashMap<bytes::Bytes, (mpsc::Sender<MutinyWSCommand>, broadcast::Sender<bool>)>>>;
Expand Down Expand Up @@ -280,7 +281,7 @@ async fn handle_mutiny_ws(
// Currently they send one every 5s, so that's 2 chances before timing out.
// This might be too aggressive but we can judge that based on usage and warning logs.
let mut ping_timeout = Box::pin(tokio::time::timeout(
std::time::Duration::from_secs(11),
std::time::Duration::from_secs(PING_TIMEOUT),
futures::future::pending::<()>(),
));

Expand Down Expand Up @@ -316,7 +317,7 @@ async fn handle_mutiny_ws(
},
MutinyProxyCommand::Ping => {
ping_timeout = Box::pin(tokio::time::timeout(
std::time::Duration::from_secs(15),
std::time::Duration::from_secs(PING_TIMEOUT),
futures::future::pending::<()>()
));
},
Expand Down

0 comments on commit eeba5e5

Please sign in to comment.