1

I'm trying to create a webrtc data channel between client to server. (the data is different between each client so i need a unique connection between each client to my server)

After some research i concluded that i need to use a turn server and when a client connects to the turn server on the server side i need to act as the other peer and create the data channel, at least that what i think.

I don't need any signalling only pure webrtc connection. i tried to use this turn server https://github.com/coturn/coturn but i will deeply appreciate any working example for server to client data channel without any signalling just pure webrtc. Thanks A lot!:)

Thomas
  • 1,445
  • 14
  • 30
avi dahan
  • 539
  • 3
  • 19

3 Answers3

2

You need a signalling server to interchange SDP between the browser and whatever the browser talks to in order to set up the call. This signalling server can be the same as your media server - but it doesn't have to be. If your media server is on the open Internet, you don't need a TURN server. If it's behind another NAT, you'll need one.

  • https://www.google.co.il/amp/s/bloggeek.me/siganling-protocol-webrtc/amp/ – avi dahan Jan 22 '18 at 14:21
  • As you can see in the link above signaling can also be done via data channel means the entire connection is via WebRTC and the server also acts as the peer, that’s the example I would like to get – avi dahan Jan 22 '18 at 14:22
  • You do understand that's my website and post you're pointing to here :-) You can use the data channel for signaling, but in order to open it, you'll need to first make the initial connection using an external signaling connection - probably via a websocket or over HTTPS – Tsahi Levent-Levi Jan 22 '18 at 14:29
  • nice, i didn't notice:). but i am sure there is a way to use only webrtc to establish a connection between the server and the client because some companies use it to bypass adblock and such. – avi dahan Jan 23 '18 at 12:17
  • if i'm using turn server as the server side and then when a clients connect to my turn server i'm just grabbing the connection between the client and my server. – avi dahan Jan 25 '18 at 09:29
1

You've got it all wrong...

To get WebRTC started, you'll need a signaling server. To be able to connect one browser to another, you first need the two browsers to exchange SDP blobs between them. And for that, you need some signaling server to coordinate this process (also known as offer-answer).

Once you get these messages going via a signaling server, you might end up needing a TURN server (and most likely will need a STUN server - which you get for free from most TURN server implementations). The TURN server will relay your data channel's traffic if the browsers will be unable to communicate directly peer-to-peer.

There are quite a few signaling servers out there for you to use. Here's one to try out: https://github.com/feross/simple-peer

Tsahi Levent-Levi
  • 2,351
  • 2
  • 18
  • 26
  • 2
    First I really appreciate your answer, but I think you got it all wrong because I didn’t want browser to browser WebRTC but server to browser data channel and for this type of communication you don’t need signaling. – avi dahan Jan 21 '18 at 12:34
  • 1
    For browser to browser you do need SDP , but if I will use turn server and instead of the other peer the server will grab the connection , there are several implementations of this kind of connections but unfortunately not open source. – avi dahan Jan 21 '18 at 20:26
  • As Tsahi explained, you will need signaling even if you use WebRTC connect a browser to a server. – jamix Jan 22 '18 at 08:23
1

I totally understand what you want to achieve here, in fact we had the same requirement in our project too.

Please have a look at the answer I have at: WebRTC Data Channel server to clients UDP communication. Is it currently possible?

Miao ZhiCheng
  • 617
  • 7
  • 9