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

Enhance hole punching #20

Open
wants to merge 2 commits into
base: decentralized-hole-punching
Choose a base branch
from

Conversation

optman
Copy link

@optman optman commented Feb 24, 2022

We can try to establish direct connection before transfer (while hole-punching is going on background). I also enable libp2p "p2p-holepunching" log when -debug flag set, so we can see why hole punching fail (in my case it will mostly timeout with the default dial timeout value).

@dennis-tra
Copy link
Owner

With the new decentralized hole punching, there is a connection reversal mechanism. I could imagine that this step here is not really necessary. I'll give it a try!

@optman
Copy link
Author

optman commented Mar 10, 2022

@dennis-tra The reversal connection is auto start after the relay connection established, it may take several round trip time(maybe 10~60 seconds, depend on where the relay node is) . NewStream will settle on already available connection, it wouldn't wait the direct-connection, who know when it will be. So when transfer start immediately, it will always use the only (relay) connection.

@dennis-tra
Copy link
Owner

So you want to make sure we actually use a direct connection for the new stream that gets created a couple of lines later, right?

@optman
Copy link
Author

optman commented Mar 10, 2022

yes, try to create direct connection is one way to check hole-punch is completed, I don't think there is other better way.

@dennis-tra
Copy link
Owner

There's the option to pass a tracer into the EnableHolePunch libp2p option. I thought of listening for the StartHolePunchEvt and EndHolePunchEvtevents:

https://github.com/libp2p/go-libp2p/blob/f0db9cc407a2982faa5a04563ad5fc48326932ce/p2p/protocol/holepunch/tracer.go#L90

@optman
Copy link
Author

optman commented Mar 10, 2022

Good idea, I didn't thought tracer can be used in these ways, but it should work. :)

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.

None yet

2 participants