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

Make stream timeout and maximum concurrent streams per connection configurable in the identify protocol. #5653

Open
vbhattaccmu opened this issue Oct 29, 2024 · 0 comments

Comments

@vbhattaccmu
Copy link

Description

I would like to propose the following two constants, namely :-

  1. stream_timeout
  2. max_concurrent_streams_per_connection

defined here be made configurable via Identify Behaviour config defined here.

Motivation

In a large peer-to-peer (p2p) network with a lot of peers attempting to a dial a peer via swarm, some subsequent IdentifyReceived events are never triggered due to the active streams timing out or not having enough concurrent streams configured per connection.

Currently there is no way to increase this timeout or allow more concurrent streams as they are hardcoded to 60s and 10 respectively on identify handlers.

I would love to have these two attributes be made configurable such that the user inheriting the library can choose to set a value from config and the default be set to the original 60s and 10 respectively.

Current Implementation

Current implementation:

/protocol/identify/src/handler.rs

const STREAM_TIMEOUT: Duration = Duration::from_secs(60);
const MAX_CONCURRENT_STREAMS_PER_CONNECTION: usize = 10;
/protocol/identify/src/handler.rs

impl Handler {
    /// Creates a new `Handler`.
    pub fn new(
        interval: Duration,
        remote_peer_id: PeerId,
        public_key: PublicKey,
        protocol_version: String,
        agent_version: String,
        observed_addr: Multiaddr,
        external_addresses: HashSet<Multiaddr>,
    ) -> Self {
        Self {
            remote_peer_id,
            events: SmallVec::new(),
            active_streams: futures_bounded::FuturesSet::new(
                STREAM_TIMEOUT,
                MAX_CONCURRENT_STREAMS_PER_CONNECTION,
            ),
            ...

Are you planning to do it yourself in a pull request ?

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant