-
Notifications
You must be signed in to change notification settings - Fork 108
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
fix(bitswap): increase timeout to ensure hole punching completes #651
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
Triage note:
|
connectionTimeout here is not necessary since defaultNewStreamTimeout was introduced upstream in libp2p/go-libp2p#2907
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some spelunking we realized this timeout is no longer necessary, refactored this PR to reflect that. LGTM.
go-libp2p now has implicit ones for both Dial and NewStream:
https://github.com/libp2p/go-libp2p/blob/v0.36.1/p2p/net/swarm/swarm.go#L28-L36
(With libp2p/go-libp2p#2907 being the default in go-libp2p 0.36, we have implicit timeout of 15s on stream as well)
…s#651) Co-authored-by: Marcin Rataj <[email protected]>
What's in this PR
This PR increases the Bitswap connection timeout from 5 seconds to 10 seconds. This is based on testing that shows that when one of the peers is behind NAT and holepunching is necessary, it can take a little bit over 5 seconds only for hole punching to succeed.
Hole punching slowness will be handled independently in libp2p/go-libp2p#2898.
This issue aims to prevent bitswap connection timeouts that would otherwise succeed, if given a higher connection timeout. Increasing the timeout appears to be an effective workaround based on some testing.
Based on https://github.com/ipfs/go-bitswap/pull/477/files, it appears that the 5 second timeout was an arbitrary starting that was picked in 2021, prior to which there was no time out. Here's the source of the suggestion of a 5 second timeout.