arj03 / ssb-browser-core

ssb-server in a browser
Other
50 stars 8 forks source link

Add DHT support #45

Closed KyleMaas closed 3 years ago

KyleMaas commented 3 years ago

Figured I'd pick this back up again now that @staltz integrated my Hyperswarm changes into multiserver-dht version 5.0.0. As evidenced by #43, rooms as they currently are are not terribly intuitive until you understand how they're supposed to work, and it would be awfully nice if we had DHT support for connecting without having to use more centralized infrastructure like Rooms 2.0.

This has been updated to use public versions (not based on my repos) of the DHT stuff with only a couple minor patches. This is runnable as-is and does seem to function, although there is one error that gets logged that I don't quite understand:

method:tunnel,ping is not in list of allowed methods

@arj03 Any idea what would cause this, or even if it's an error we care about?

arj03 commented 3 years ago

That error should be explained here: https://github.com/arj03/ssb-browser-core/blob/8066a7a25a60fcf2ca12247bea33af4bd0745d09/net.js#L109 So it seems like you are connected to a peer that does not support tunnel ping?

arj03 commented 3 years ago

I'll try testing this over the next couple of days. Would be nice to have https://gitlab.com/staltz/ssb-dht-invite/-/merge_requests/1 merged.

arj03 commented 3 years ago

And thanks for the PR, the changes looks quite small :-)

staltz commented 3 years ago

ssb-dht-invite@2.0.0 published, sorry I hadn't noticed the gitlab repo

KyleMaas commented 3 years ago

Perfect! That will make this much easier. Thanks!

I suspect it will solve a lot of the problems Manyverse has with NAT, too. Hyperswarm has much better hole punching.

staltz commented 3 years ago

Hyperswarm has much better hole punching.

This hasn't been my experience, but I can try. Nowadays I believe that if a DHT connection doesn't work 2% of the time, that's too high occurrence. We'd need failures limited to 0.01% maximum.

KyleMaas commented 3 years ago

Hyperswarm has much better hole punching.

This hasn't been my experience, but I can try. Nowadays I believe that if a DHT connection doesn't work 2% of the time, that's too high occurrence. We'd need failures limited to 0.01% maximum.

Hm. What issues are you running into with it? Because it's worked very reliably for me, whereas the previous DHT stuff tended to not work at all for me behind NAT.

staltz commented 3 years ago

What issues are you running into with it?

Connections over DHT not finalizing within 2 minutes of waiting. Reliability varies heavily with what mobile ISP you have. Your experience in your country may differ vastly from my location, or other users' locations.

KyleMaas commented 3 years ago

Hm. I'll have to try that out some more with this and see if I can duplicate it. So far I've been trying it on WiFi behind NAT, where Manyverse's DHT implementation didn't work before and the Hyperswarm version does. But I don't think I've tested on mobile yet.

arj03 commented 3 years ago

This looks good. Thanks!