8

I am wondering whether it is possible for two clients to set up a websocket connection with each other, given that they have some help from the server to "locate" each other.

Currently there are messages going from a client to the server through websockets. The server simply redirects that msg to the client that needs to receive it, so I wondering if it is just possible to skip the middleman.

That is just having the server tell the two clients that need to communicate some info about one another so that they can start a websocket connect with each other. '

Is this possible? or are there some other possible issues with this

JerryFox
  • 615
  • 2
  • 13
  • 25

3 Answers3

7

This isn't possible through Web Sockets today. However, you can use WebRTC which has robust methods of establishing a peer to peer connection.

WebRTC is typically used for video conferencing applications, but a data channel is set up as well.

There is a lot to WebRTC. You can find an example here: http://www.html5rocks.com/en/tutorials/webrtc/datachannels/

Brad
  • 159,648
  • 54
  • 349
  • 530
  • funny because I was initially asking to use this as the signaling to set up the webRTC connection :] – JerryFox Jul 24 '14 at 20:10
  • @JerryFox Ah, well for that you have to use all of the STUN and TURN and what not. Fortunately, there is a lot of off-the-shelf Node.js code for doing this. – Brad Jul 24 '14 at 20:11
1

Based on my experience, you can do communicate client to client using Channels. This will only work if they're on the same Network, same subnet and have multicast enabled.

Ray A
  • 447
  • 2
  • 5
0

Using webrtc it's possible. Read this manual Webrtc manual or read the book Real-Time Communication with WebRTC: Peer-to-Peer in the Browser

Sensei James
  • 2,617
  • 30
  • 36
Jijo John
  • 1,375
  • 9
  • 21