meetecho / janus-gateway

Janus WebRTC Server
https://janus.conf.meetecho.com
GNU General Public License v3.0
7.99k stars 2.45k forks source link

GStreamer WebRTC <-> Janus Gateway DTLS error #1493

Closed petergerten closed 5 years ago

petergerten commented 5 years ago

Hi, I try to establish a WebRTC connection between the gstreamer webrtc implementation and Janus Gateway (streaming plugin specifically).

After I send the SDP answer to Janus as well as all trickle candidates, I get DTLS errors and finally a DTLS timeout. I searched a bit and found one thread where someone else experienced the same issue but it was never resolved: https://github.com/centricular/gstwebrtc-demos/issues/27

Admin Output just before DTLS timeout (see high DTLS retransmission count): https://pastebin.com/qFBctiyS

Does anyone has a suggestion on how to solve this?

Peter

petergerten commented 5 years ago

This is the debug output on gstreamer side with GST_DEBUG=dtls:6: https://pastebin.com/dHa8sfLw

lminiero commented 5 years ago

I'm not familiar with how the DTLS works in gstreamer, sorry, you should ask them. Try capturing the traffic to see if DTLS handshake messages are being exchanged at all: if we're retransmitting it's because we're not getting answers/feedback to what we send.

petergerten commented 5 years ago

Thanks, Lorenzo. I just checked with wireshark and did not see any DTLS packets on the wire. (with another janus client I see them though). Strange - will check further what is going on...

petergerten commented 5 years ago

From what is visible in the admin data https://pastebin.com/qFBctiyS - is it conclusive that the next stage would be the sending of a DTLS handshake by the gstreamer side? Some of the gstreamer devs said on similar issues that the ICE process was probably not finished yet. But from what I can see there is a selected pair.

saket424 commented 5 years ago

@petergerten I am curious on this topic also. Can you share the gstreamer webrtc pipeline you have been experimenting so far with so I can try to reproduce your issue. Thanks

petergerten commented 5 years ago

@saket424 As using webrtc with gstreamer is not a simple pipeline but rather code with handlers I do not have a minimal example to reproduce the issue at this point. I will look into this though.

petergerten commented 5 years ago

@lminiero From the admin output https://pastebin.com/qFBctiyS , would you say that the next step is the DTLS handshake to be initiated by the gstreamer side or is there a possibility of any other step that is still missing?

petergerten commented 5 years ago

What I don't understand is this:

                        "dtls-role": "passive",
                        "dtls-state": "trying",
                        "retransmissions": 197,

As far as I understand DTLS role "passive" on Janus side indicates that the other side needs to initiate the DTLS handshake. When I captured the above admin info, there were zero DTLS packets going over the wire (checked with wireshark). What exactly is Janus doing when it counts up the "retransmissions" ? Does that just mean it is waiting for the other side to send a DTLS handshake?

petergerten commented 5 years ago

After further investigation I found that gstreamer did not automatically add the ICE candidates from the SDP and I had to manually add them. (I wrongly assumed I only have to do that for trickle candidates) After that - all is fine and the DTLS handshake works :-)

lminiero commented 5 years ago

What exactly is Janus doing when it counts up the "retransmissions" ? Does that just mean it is waiting for the other side to send a DTLS handshake?

No, it means a call to DTLSv1_get_timeout() told us a DTLS timer expired. Since this is usually associated to something we sent and didn't get a response to, we increase an internal counter called retransmissions (which is what you see in the Admin API). I guess that it can also happen when the DTLS stack is waiting for a start and it doesn't arrive, which is your scenario: in that case, yes, the retransmission counter is misleading. I'll think of a way to fix that.

After further investigation I found that gstreamer did not automatically add the ICE candidates from the SDP and I had to manually add them. (I wrongly assumed I only have to do that for trickle candidates) After that - all is fine and the DTLS handshake works :-)

Ah, nice: so probably ICE was completed for us, but not for gstreamer, which is why they never started the DTLS handshake. Closing then.

saket424 commented 5 years ago

@petergarten, I would appreciate an example and associated code and handlers for others who may want to reproduce the gst-webrtc and Janus interworking success that you had so they can use that as a starting point Many thanks.

lminiero commented 5 years ago

Please discuss that offline, it's off topic here.