Different ways to send data/text via Janus

551 views
Skip to first unread message

skofo

unread,
May 16, 2022, 11:05:29 AM5/16/22
to meetecho-janus
Hello,

I am currently implementing a Janus SFU interface for the gaming engine Unity using their own RenderStreaming/WebRTC implementation. So far, I can send video and audio streams between all clients, so the most important things are already working :) 

However, the data channels are unfortunately not working. Unity sends an offer to Janus including the data channel and is also able to send data to Janus, which Janus recognizes. Subscribers also receive the correct offer including the data channel and answer appropriately. The ICE connection is successfully completed. Unfortunately, the "pc.onDataChannel" method of the subscribers is then never called. 

Therefore, I have several questions:

1. Is there another way to relay messages via Janus? strings would be enough, as we can send all data in a JSON format and the size of those packages would be rather small. 
2. General Question: When exactly should the "pc.onDataChannel" callback be invoked? When the ICE connection was successful or only when the first data arrives on that channel?
3. Is there a way to see to what endpoints Janus sends data to so that I can check whether the data is being sent by Janus?

Here is the offer a subscriber receives from Janus:

"jsep": {
"type": "offer",
"sdp": "v=0\r\no=- 1652698575225406 1 IN IP4 164.90.176.95\r\ns=VideoRoom exhibition-h264\r\nt=0 0\r\na=group:BUNDLE 0\r\na=ice-options:trickle\r\na=fingerprint:sha-256 E6:CD:63:25:3A:5D:FD:9E:A8:C5:ED:E3:E8:58:9D:18:D0:5A:B4:74:13:8C:42:F3:E0:BF:C8:32:AE:2B:57:C0\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS janus\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 164.90.176.95\r\na=sendonly\r\na=mid:0\r\na=sctp-port:5000\r\na=ice-ufrag:A+S/\r\na=ice-pwd:d9X1i3QqwysJk3WbeTs/Xr\r\na=ice-options:trickle\r\na=setup:actpass\r\na=mid:0\r\n"
}

And here the answer being sent by Unity 

"jsep":{
"type":"answer",
"sdp":"v=0\r\no=- 7811705463152725371 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=application 55406 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 10.1.8.127\r\na=candidate:3880229 1 udp 2122260223 10.1.8.127 55406 typ host generation 0 network-id 1 network-cost 50\r\na=ice-ufrag:Shk9\r\na=ice-pwd:gDVVYjI1S4v7NNRXEjnBx0Sp\r\na=ice-options:trickle\r\na=fingerprint:sha-256 DD:E6:DD:91:FD:5C:9E:42:22:2E:C2:AC:C9:53:04:C3:C2:9E:3D:8C:CF:F0:34:53:0A:42:99:B4:A7:AD:17:A5\r\na=setup:active\r\na=mid:0\r\na=sctp-port:5000\r\n"
}

Lastly, an excerpt from the logs:



janus-webrtc_1 | [944333584760947] Incoming SCTP contents: HalloJanus

janus-webrtc_1 | Got a text DataChannel message (10 bytes) to forward

janus-webrtc_1 | [944333584760947] Looks like DTLS!

janus-webrtc_1 | [944333584760947] Written 77 bytes on the read BIO...

janus-webrtc_1 | [944333584760947] ... and read 40 of them from SSL...

janus-webrtc_1 | [944333584760947] Any data available?

janus-webrtc_1 | [944333584760947] Sending data (40 bytes) to the SCTP stack...

janus-webrtc_1 | [944333584760947] Data from DTLS to SCTP stack: 40 bytes

janus-webrtc_1 | [944333584760947] SCTP data received of length 10 on channel with id 0.

janus-webrtc_1 | [944333584760947] Incoming SCTP contents: HalloJanus

Kind regards,
Moritz

Lorenzo Miniero

unread,
May 17, 2022, 3:10:01 AM5/17/22
to meetecho-janus
You can check what the Streaming plugin demo does when datachannels are negotiated, as that would be pretty much the same scenario. It's easy to setup, since you just need to create a mountpoint with a data port, and then you can use nc to send UDP messages to that port and they should be sent to the browser.

L.

skofo

unread,
Jun 2, 2022, 12:24:38 PM6/2/22
to meetecho-janus
Finally managed to get it to work with opening up the default data channel following the approach in janus.js and the thread here. https://groups.google.com/g/meetecho-janus/c/vOkIkW2c0Gs

Suggestion: Maybe adding a default data channel to each subscriber should be also mentioned in the docs? 

Reply all
Reply to author
Forward
0 new messages