holepunchto / hyperswarm-dht-relay

Relaying the Hyperswarm DHT over other transport protocols to bring decentralized networking to everyone
ISC License
44 stars 10 forks source link

Invalid reject/open when both a protomux channel and core/corestore replication stream across relay via WebSocket #25

Open zacharygriffee opened 12 months ago

zacharygriffee commented 12 months ago

Hello! I originally posted this as an issue with corestore, but dug deep and found it was a hyperswarm-dht-relay issue.

When a corestore/core is replicated with protomux channels on a dht-relay websocket, it causes 'invalid reject/open' messages.

I have tried every variation of protomux <-> socket <-> replicate combinations and even tried with delays and 'using a channel to replicate the corestore/core after a delay'.

Here is a pastebin of the code that fails: https://pastebin.com/1NMCrgkK . The same code done over 'standard hyperdht' succeeds flawlessly.

This function of protomux https://github.com/holepunchto/protomux/blob/d3d6f8f55e52c2fbe5cd56f5d067ac43ca13c27d/index.js#L574 is where the error occurs as well as invalid open message.

zacharygriffee commented 11 months ago

I've created a FORK of this repo that has the failing tests I'm mentioning. I'm going to see if I can fix the issue as well. But this is at a different direction of my expertise.

https://github.com/zacharygriffee/hyperswarm-dht-relay/blob/main/test/replication.mjs

zacharygriffee commented 5 months ago

I've found that this issue also breaks the new version of Autobase (version 6.x.x) for me in the browser.

zacharygriffee commented 4 months ago

Just wanted to say that I found a way to make this work in browser utilizing webrtc as the main connection through this npm library:

https://github.com/LuKks/hyper-webrtc

It still requires the use of dht-relay for peer discovery but then hands off to webrtc to handle direct browser connection.

I created a dht-relay server and added very heavy rate-limiting to only promote peer discovery to facilitate the browser connection.

This is working well, and replication of corestore, autobase, and other tools while simultaneously utilizing custom channels of my own work well now in the browser via the webrtc.