Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update stream limits and connection limits #53

Merged
merged 10 commits into from
Apr 15, 2023
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 17 additions & 8 deletions packages/frontend/src/lib/libp2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@ import { BOOTSTRAP_NODE, CHAT_TOPIC, CIRCUIT_RELAY_CODE } from './constants'
import * as filters from "@libp2p/websockets/filters"

// @ts-ignore
import { circuitRelayTransport, circuitRelayServer } from 'libp2p/circuit-relay'
import { circuitRelayTransport } from 'libp2p/circuit-relay'


export async function startLibp2p() {
// localStorage.debug = 'libp2p*,-*:trace'
// application-specific data lives in the datastore

// libp2p is the networking layer that underpins Helia
const libp2p = await createLibp2p({
dht: kadDHT({protocolPrefix: "/universal-connectivity", maxInboundStreams: 100, maxOutboundStreams: 100, clientMode: true}),
// set the inbound and outbound stream limits to these values
// because we were seeing a lot of the default limits being hit
dht: kadDHT({
protocolPrefix: "/universal-connectivity",
maxInboundStreams: 5000,
maxOutboundStreams: 5000,
clientMode: true
}),
transports: [webTransport(), webSockets({
filter: filters.all,
}), webRTC({
Expand All @@ -45,7 +51,7 @@ export async function startLibp2p() {
}),],
connectionEncryption: [noise()],
connectionManager: {
maxConnections: 200,
maxConnections: 10,
minConnections: 1,
},
streamMuxers: [yamux()],
Expand All @@ -64,12 +70,15 @@ export async function startLibp2p() {
ignoreDuplicatePublishError: true,
}),
identify: {
maxPushOutgoingStreams: 100,
maxInboundStreams: 100,
maxOutboundStreams: 100,
// these are set because we were seeing a lot of identify and identify push
// stream limits being hit
maxPushOutgoingStreams: 1000,
maxPushIncomingStreams: 1000,
maxInboundStreams: 1000,
maxOutboundStreams: 1000,
Comment on lines +69 to +74
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am concerned by this. These limits are per connection, this means you're allowing 1000 identify streams to be open at the same time on each connection.

If you're seeing errors it sounds like something's not cleaning up the streams.

Maybe related: libp2p/js-libp2p#1424

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do what you have to to appease the demo gods though - this is more of a note to self to investigate.

Copy link
Member Author

@p-shahi p-shahi Apr 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the upper bounds here are crazy, but we were hitting the limits quite often so set it arbitrarily high

},
autonat: {
startupDelay: 60 * 60 *24 * 1000,
startupDelay: 60 * 60 * 24 * 1000,
},
})

Expand Down