Problems with data channels

720 views
Skip to first unread message

Christophe Chaillon

unread,
Feb 17, 2021, 12:12:40 PM2/17/21
to meetecho-janus
Hi,

I am working on a c++ application which will run on Windows and Android.
I successfully configured the application and the Janus server for the video and the audio, but the data channels don't seem to work.

Context : 
Janus version 0.10.4 compiled with data_channels = true
Plugin VideoRoom with the default example room 1234
libWebRTC m84

I put the data=true flag on the publisher and the subscriber
I created a data channel on the publisher (mPeerConnection->CreateDataChannel) with the name "JanusDataChannel"
I see the 3 bundles (audio, video and application) in the DSP of the publisher and the subscriber
I see that Janus received something because there is "[janus.plugin.videoroom] Data channel available" in the log
The data channel of the publisher gets the state "opened" and I can send data without error.
But at the end, the OnDataChannel method of the subscriber is never called...

Do you have an idea ?
Is there something on the Janus admin page or in the log that can help me to understand the root of the problem ?

Thanks,

Christophe

Christophe Chaillon

unread,
Feb 22, 2021, 10:10:30 AM2/22/21
to meetecho-janus
Hi,

Some news:
I switched to a fresh compiled Janus 0.11.1
I have 2 clients each one has a publisher and a subscriber (as I said video and audio are ok)
With the verbose logs (and some additionals logs), I can see that my messages arrive to the server but it doesn't forward them because the session is not "dataready"

I think that there is a problem with the VideoRoom plugin.
The plugin doesn't forward data to the session of the subscriber if the session is not "dataready"
But, the plugin doesn't open the data channel of the subscriber (so the session will never be "dataready") if there is no data to forward...

I tried to remove the "dataready" test and it seems to work... OnDataChannel is called on the subscribers and all the messages are received

index 5c517dc9..b221936f 100644
--- a/plugins/janus_videoroom.c
+++ b/plugins/janus_videoroom.c
@@ -8007,7 +8007,7 @@ static void janus_videoroom_relay_data_packet(gpointer data, gpointer user_data)
        if(!session || !session->handle) {
                return;
        }
-       if(!g_atomic_int_get(&session->started) || !g_atomic_int_get(&session->dataready)) {
+       if(!g_atomic_int_get(&session->started)) {
                return;
        }
        if(gateway != NULL && packet->data != NULL) {


Am I right ? Or do I make a mistake ?

Thanks,

Christophe


--
You received this message because you are subscribed to a topic in the Google Groups "meetecho-janus" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/meetecho-janus/vOkIkW2c0Gs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to meetecho-janu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/meetecho-janus/f74a1d61-e68e-416a-aa6a-a8228a45d947n%40googlegroups.com.

Lorenzo Miniero

unread,
Feb 22, 2021, 12:14:56 PM2/22/21
to meetecho-janus
The core expects subscribers to create a default datachannel first. See janus.js for an example.

L.

Jean-Daniel

unread,
May 24, 2022, 11:19:13 AM5/24/22
to meetecho-janus
I have the same issue, and having trouble understanding what you mean by "create a default data channel".

I tried to call `createDataChannel` on my Peer connection before subscribing and so before setting remote description and returning the answer in `start` message, and still never receive a `OnDataChannel` event on subscriber side.

When and how should the data channel on subscriber side be created ? 

Lorenzo Miniero

unread,
May 25, 2022, 3:35:09 AM5/25/22
to meetecho-janus
I think that's exactly what we do in janus.js, e.g., for Streaming plugin data mountpoints, and it works for me:

I don't know if anything else is required, possibly just an incoming data message from Janus that would open the channel in the other direction too? Try playing with the Streaming plugin demo, adding a data mountpoint that you can feed with something like nc to simulate data, to see the sequence of steps that is followed there.

L.

Jean-Daniel

unread,
May 25, 2022, 4:00:08 AM5/25/22
to meetecho-janus
Thank you. 

I finally managed to make it work by creating the data channel after the initial setRemoteSessionDescription call (just before creating the answer).
After that, Janus properly open a new data channel for each publisher when they first send a message (I have a onDataChannel event for each sender).

skofo

unread,
May 30, 2022, 12:12:02 PM5/30/22
to meetecho-janus
This sounds very similar to the issues I am facing with implementing data channels for the Unity game engine! -> see this post https://groups.google.com/g/meetecho-janus/c/ZVl8-f7mpQM

Will try implementing your solution and thanks for the input!

skofo

unread,
Jun 7, 2022, 7:20:00 AM6/7/22
to meetecho-janus
So, while this works in general, I ran into another problem implementing it this way. When I create a data channel using createDataChannel on the subscriber peer, the WebRTC.dll automatically creates an offer and tries to send it to Janus. Is that the expected behavior?

Lorenzo Miniero

unread,
Jun 8, 2022, 2:55:19 AM6/8/22
to meetecho-janus
You have to create the data channel *after* you receive the offer, not before.

L.

skofo

unread,
Jun 13, 2022, 11:47:20 AM6/13/22
to meetecho-janus
Yep, that was it. Works like a charm now, thanks!
Reply all
Reply to author
Forward
0 new messages