Can HTML5 Websockets connect 2 clients (browsers) directly without using a server? (P2P)

HtmlP2pWebsocket

Html Problem Overview


Using HTML5 Websockets, can I open a socket directly between 2 clients (browsers) (assuming I know their IP addresses and there are no NAT traversal issues). I want to send some data directly from one browser to another browser, essentially creating a P2P network. Everything I've read so far on the web, websockets are all used to communicate between client and server, but nothing about client to client.

Html Solutions


Solution 1 - Html

No

Already answered here for more details: https://stackoverflow.com/questions/4118272/do-websockets-allow-for-p2p-browser-to-browser-communication

Update:

The WebRTC protocol and API is making rapid progress and allows a Data Channel to be established between two peers (you still may need a STUN/TURN server for the initial NAT traversal and setup).

Solution 2 - Html

From past to future: Pick your implementation.

  • Most modern browsers support peer to proxy to peer using Websockets.
  • Peer to peer is only available using certain browsers plug-ins for example Opera Unite and FireFox Pow.
  • Major browsers are in the process of implementing WebRTC which will allow peer to peer.

Solution 3 - Html

If you just don't want to implement server your self you can use https://httprelay.io . No additional libraries required, all communication based on simple AJAX calls.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJustinView Question on Stackoverflow
Solution 1 - HtmlkanakaView Answer on Stackoverflow
Solution 2 - Htmluser656925View Answer on Stackoverflow
Solution 3 - HtmlJonasView Answer on Stackoverflow