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

Use the same port for TCP and WebSocket #2684

Closed
NihiliumOnMarz opened this issue Jan 14, 2024 · 6 comments · Fixed by #2984
Closed

Use the same port for TCP and WebSocket #2684

NihiliumOnMarz opened this issue Jan 14, 2024 · 6 comments · Fixed by #2984
Labels
kind/enhancement A net-new feature or improvement to an existing feature P3 Low: Not priority right now

Comments

@NihiliumOnMarz
Copy link

NihiliumOnMarz commented Jan 14, 2024

I am trying to listen on /tcp/1111, /tcp/1111/ws, and /tcp/1111/tls/ws and getting error bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."}

I thought LibP2P was capable of this?

@Jorropo
Copy link
Contributor

Jorropo commented Jan 15, 2024

This has to be implemented manually in each transport (see https://grep.app/search?q=quicreuse&filter[repo][0]=libp2p/go-libp2p).
AFAIK this is only implemented across quic* and webrtc transports now.

@NihiliumOnMarz
Copy link
Author

This has to be implemented manually in each transport (see https://grep.app/search?q=quicreuse&filter[repo][0]=libp2p/go-libp2p). AFAIK this is only implemented across quic* and webrtc transports now.

Looking through the code in TCP transport it has an option for reuse port but I do not see it in websocket transport. Is there an easy way to add?

@Stebalien
Copy link
Member

Looking through the code in TCP transport it has an option for reuse port but I do not see it in websocket transport. Is there an easy way to add?

Not easily, no. It's not just a matter of saying "reuse this port", you need to be able to detect that the connection is not for you and pass it off to the correct transport.

@sukunrt sukunrt changed the title TCP Bind issue Use the same port for TCP and WebSocket Jan 24, 2024
@sukunrt sukunrt added the kind/enhancement A net-new feature or improvement to an existing feature label Jan 24, 2024
@MarcoPolo
Copy link
Collaborator

@NihiliumOnMarz is there a specific use case you need this for?

@Jorropo
Copy link
Contributor

Jorropo commented Mar 16, 2024

Related libp2p/specs#608 I'll submit a PoC.

@sukunrt sukunrt added the P3 Low: Not priority right now label Apr 25, 2024
@aschmahmann
Copy link
Collaborator

is there a specific use case you need this for?

I'd like to have this in kubo. In particular, ipfs/kubo#10521 will allow us to automatically grant people WSS connections that are usable from browsers (see #1360) alongside other libp2p connection types (e.g. TCP+TLS/Noise + Yamux, or QUIC). Getting people to open up new ports with their docker configs, firewall rules, port forwarding, etc. is generally a pain and seems likely to hurt adoption. So if we can reuse the TCP port for WSS connections that would be pretty convenient.

@Jorropo my guess is that we can probably reuse a chunk of the investigative work (and perhaps some of the code) from the magiselect proposal here (thanks for that 🙏), and get some of the work landed even if the "look at magic bytes instead of using multistream select" proposal hasn't landed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A net-new feature or improvement to an existing feature P3 Low: Not priority right now
Projects
None yet
6 participants