diff --git a/packages/beacon-node/src/network/libp2p/index.ts b/packages/beacon-node/src/network/libp2p/index.ts index 4540cae67974..4bdc23d2f891 100644 --- a/packages/beacon-node/src/network/libp2p/index.ts +++ b/packages/beacon-node/src/network/libp2p/index.ts @@ -75,6 +75,10 @@ export async function createNodeJsLibp2p( transports: [ tcp({ maxConnections: networkOpts.maxPeers, + // socket option: the maximum length of the queue of pending connections + // https://nodejs.org/dist/latest-v18.x/docs/api/net.html#serverlisten + // this is 10% of our target peers + backlog: 5, closeServerOnMaxConnections: { closeAbove: networkOpts.maxPeers ?? Infinity, listenBelow: networkOpts.maxPeers ?? Infinity, @@ -101,6 +105,9 @@ export async function createNodeJsLibp2p( //maxConnections: options.maxConnections, // DOCS: There is no way to turn off autodial other than setting minConnections to 0 minConnections: 0, + // the maximum number of pending connections libp2p will accept before it starts rejecting incoming connections. + // make it the same to backlog option above + maxIncomingPendingConnections: 5, }, datastore, services: {