diff --git a/packages/interfaces/src/libp2p.ts b/packages/interfaces/src/libp2p.ts index 522b96cf5e..51905fa7a4 100644 --- a/packages/interfaces/src/libp2p.ts +++ b/packages/interfaces/src/libp2p.ts @@ -29,4 +29,5 @@ export type CreateLibp2pOptions = Libp2pOptions & { * @default false */ hideWebSocketInfo?: boolean; + pingMaxInboundStreams?: number; }; diff --git a/packages/sdk/src/utils/libp2p.ts b/packages/sdk/src/utils/libp2p.ts index 4cc31f702d..caf64829ea 100644 --- a/packages/sdk/src/utils/libp2p.ts +++ b/packages/sdk/src/utils/libp2p.ts @@ -19,7 +19,11 @@ import { wakuGossipSub } from "@waku/relay"; import { ensureShardingConfigured } from "@waku/utils"; import { createLibp2p } from "libp2p"; -import { CreateWakuNodeOptions, DefaultUserAgent } from "../waku.js"; +import { + CreateWakuNodeOptions, + DefaultPingMaxInboundStreams, + DefaultUserAgent +} from "../waku.js"; import { defaultPeerDiscoveries } from "./discovery.js"; @@ -70,7 +74,10 @@ export async function defaultLibp2p( identify: identify({ agentVersion: userAgent ?? DefaultUserAgent }), - ping: ping(), + ping: ping({ + maxInboundStreams: + options?.pingMaxInboundStreams ?? DefaultPingMaxInboundStreams + }), ...metadataService, ...pubsubService, ...options?.services diff --git a/packages/sdk/src/waku.ts b/packages/sdk/src/waku.ts index a68a317611..959d57ad88 100644 --- a/packages/sdk/src/waku.ts +++ b/packages/sdk/src/waku.ts @@ -23,6 +23,7 @@ import { subscribeToContentTopic } from "./utils/content_topic.js"; export const DefaultPingKeepAliveValueSecs = 5 * 60; export const DefaultRelayKeepAliveValueSecs = 5 * 60; export const DefaultUserAgent = "js-waku"; +export const DefaultPingMaxInboundStreams = 10; const log = new Logger("waku");