68

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.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Justin
  • 689
  • 1
  • 5
  • 3

3 Answers3

47

No

Already answered here for more details: 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).

Mike 'Pomax' Kamermans
  • 49,297
  • 16
  • 112
  • 153
kanaka
  • 70,845
  • 23
  • 144
  • 140
  • 3
    I think you need to take a look at this : http://www.html5rocks.com/en/tutorials/webrtc/basics/#toc-rtcdatachannel https://labs.ericsson.com/developer-community/blog/beyond-html5-peer-peer-conversational-video. – Mehdi Karamosly Aug 30 '13 at 22:59
  • 2
    @MehdiKaramosly, the Ericsson blog post is fairly old and is talking about the technology that became WebRTC. – kanaka Sep 03 '13 at 14:46
  • 1
    which is `peerConnection` ? – Mehdi Karamosly Sep 03 '13 at 14:56
  • 1
    peerConnection is one piece of WebRTC (it's the name for a big collection of technologies). – kanaka Sep 03 '13 at 15:20
  • As of 2017, WebRTC is a standard part of most modern browsers. See https://stackoverflow.com/a/45765379/3672465 – Beejor Aug 18 '17 at 21:48
7

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.
Community
  • 1
  • 1
3

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.

Jonas
  • 4,683
  • 4
  • 45
  • 81