datchannel in videoroom

206 views
Skip to first unread message

Srinivas Bakki

unread,
Feb 27, 2023, 6:07:50 AM2/27/23
to meetecho-janus
Hi,
     I'm looking to register a publisher and subscriber with single datachannel between them. I enabled datachannel by uncommenting "tracks.push({type: 'data' }); " and for subscriber mode i set "subscriber-mode=true" in the query string. From the logs i see that they are both creating default data channel and when sending data from subscriber i get invalid PeerConnection. 'onopen' is triggered on both sides but 'ondatachannel' is not triggered. 
Am i doing this the right way or is there something else to be done for this ?

Thanks,
Srinivas

Lorenzo Miniero

unread,
Feb 27, 2023, 6:10:29 AM2/27/23
to meetecho-janus
Subscribers can't send data, only receive it. Datachannels are monodirectional in the VideoRoom.

L.

Srinivas Bakki

unread,
Feb 27, 2023, 6:59:49 AM2/27/23
to meetecho-janus
Oh, ok. Can i be publisher on both sides and communicate ?

Lorenzo Miniero

unread,
Feb 27, 2023, 9:27:20 AM2/27/23
to meetecho-janus
If you need a bidirectional channel, just use the TextRoom.

Srinivas Bakki

unread,
Mar 1, 2023, 2:32:04 AM3/1/23
to meetecho-janus
Thank you, i put in code to create textroom plugin handle. The data channels are being created on both the sides. When i send from one end i get errors on the same datachannel as below:
    1. MessageEvent {isTrusted: true, data: '{\n "textroom": "error",\n "error_code": 413,\n …ement (text)",\n "transaction": "jVuoMLGjuHbv"\n}', origin: '', lastEventId: '', source: null, …}

On Janus server i see below error:
[ERR] [plugins/janus_textroom.c:janus_textroom_handle_incoming_request:1463] Missing mandatory element (text)

The mesage i sent is as given in the example code :
var message = {
        textroom: "message",
        transaction: randomString(12),
        room: myroom,
        text: data,
    };

textroom.data({
        text: JSON.stringify(message),
        error: function(reason) { bootbox.alert(reason); },
        success: function() { console.log("Successfully sent data\r\n"); }
    });

Lorenzo Miniero

unread,
Mar 1, 2023, 4:12:56 AM3/1/23
to meetecho-janus
If it's complaining the "text" property isn't there, I guess the value of data in your first snippet is null or undefined.

L.

Srinivas Bakki

unread,
Mar 1, 2023, 9:27:36 AM3/1/23
to meetecho-janus
Thank you,  i did make some progress converting the data to string type. However i get this error  on janus:

Got a DataChannel message (82 bytes): {"textroom":"message","transaction":"tM87rIxIHUrB","room":3456,"text":"undefined"}
[ERR] [plugins/janus_textroom.c:janus_textroom_handle_incoming_request:1507] Not in room 3456
[2428673572326236] SCTP data to send (label=JanusDataChannel, 114 bytes) coming from a plugin.

I'm unable to understand how to join room - there is below code in textroomtest.js but there's no call to the plugin, how does it join the room ?

 var register = {
                textroom: "join",
                transaction: transaction,
                room: mytxtroom,
                username: mytxtid,
                display: username
  };

Thanks,
Srinivas

Srinivas Bakki

unread,
Mar 1, 2023, 11:41:31 AM3/1/23
to meetecho-janus
Sorry, i found that code.
Reply all
Reply to author
Forward
0 new messages