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

feat: mark connections with limits as transient #1890

Merged
merged 9 commits into from
Jul 26, 2023

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Jul 25, 2023

Some connections have resources limits imposed on them, such as circuit relay connections. If these limits are breached the connection will be closed by the remote.

When this is the case, the connection will have a .transient boolean property set to true.

By default any attempt to run a protocol over a transient connection will throw (outgoing) or be reset (incoming), this is to prevent, for example, bitswap exceeding the connection transfer limit and causing the connection to be closed by the relay server when it should be reserved for the WebRTC SDP exchange to allow incoming dials.

Protocols can opt-in to being run over transient connections by specifying a runOnTransientConnection flag during libp2p.handle (incoming) and connection.openStream/libp2p.dialProtocol (outgoing).

Closes #1611

Some connections have resources limits imposed on them, such as
circuit relay connections.

When this is the case, the connection will have a `.limited` boolean
property set to true.

By default any attempt to run a protocol over a limited connection
will throw (outgoing) or be reset (incoming), this is to prevent, for
example, bitswap exceeding the connection transfer limit and causing
the connection to be closed by the relay server when it should be
reserved for the WebRTC SDP exchange.

Protocols can opt-in to being run over limited connections by specifying
a flag during `libp2p.handle` (incoming) and `connection.openStream`
(outgoing).
@achingbrain achingbrain changed the title feat: mark connections with limits as limited feat: mark connections with limits as transient Jul 26, 2023
Copy link
Member

@maschad maschad left a comment

Choose a reason for hiding this comment

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

LGTM, I think we should make mention of this configurability via runOnTransientConnection in the protocol limits docs but that could be in a follow up PR.

@achingbrain achingbrain merged commit a1ec46b into master Jul 26, 2023
17 checks passed
@achingbrain achingbrain deleted the feat/limited-streams branch July 26, 2023 15:24
@achingbrain
Copy link
Member Author

Hmm, it needs to go in the docs somewhere but I'm not sure the limits doc is the right place - that's about how to configure your node to be DOS-resistant, this feels different.

@sudiptab2100
Copy link

@maschad
Do you have any documentation for it? I'm confused how to setup the relay node and behind NAT nodes for this.

@maschad
Copy link
Member

maschad commented Apr 24, 2024

Hey @sudiptab2100 I'm not sure exactly you're referring to. If you'd like more info on setting up a Relay node you can take a look here

For more background you may want to read this

If you are still having issues feel free to open a discussion as this PR isn't the best place to discuss

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

Successfully merging this pull request may close these issues.

Add support for transient connections
3 participants