Skip to content

Commit

Permalink
feat(chain-listener): enable ws ping
Browse files Browse the repository at this point in the history
  • Loading branch information
justprosh committed Sep 17, 2024
1 parent c48f52e commit 19bb1d8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/chain-listener/src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use jsonrpsee::core::client::{Client as WsClient, Subscription, SubscriptionClie
use jsonrpsee::core::params::ArrayParams;
use jsonrpsee::core::{client, JsonValue};
use jsonrpsee::rpc_params;
use jsonrpsee::ws_client::WsClientBuilder;
use jsonrpsee::ws_client::{PingConfig, WsClientBuilder};
use libp2p_identity::PeerId;
use serde::de::DeserializeOwned;
use serde_json::{json, Value};
Expand Down Expand Up @@ -71,6 +71,7 @@ use crate::proof_tracker::ProofTracker;
use crate::types::{CUGroups, PhysicalCoreGroups};

const PROOF_POLL_LIMIT: usize = 50;
const WS_PING_PERIOD_SEC: u64 = 20;

#[derive(Clone)]
struct OnChainWorker {
Expand Down Expand Up @@ -458,6 +459,9 @@ impl ChainListener {
pub async fn create_ws_client(ws_endpoint: &str) -> Result<WsClient, client::Error> {
let ws_client = retry(ExponentialBackoff::default(), || async {
let client = WsClientBuilder::default()
.enable_ws_ping(
PingConfig::new().ping_interval(Duration::from_secs(WS_PING_PERIOD_SEC)),
)
.build(ws_endpoint)
.await
.map_err(|err| {
Expand Down

0 comments on commit 19bb1d8

Please sign in to comment.