# How to access data channels in janode when using the videoroom plugin

**URL:** <https://janus.discourse.group/t/how-to-access-data-channels-in-janode-when-using-the-videoroom-plugin/539>\
**Category:** Janode\
**Created:** [September 2, 2023, 10:33am UTC](https://janus.discourse.group/t/how-to-access-data-channels-in-janode-when-using-the-videoroom-plugin/539 "2023-09-02T10:33:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashkalor](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@ashkalor](https://janus.discourse.group/u/ashkalor)\
**Post date:** [September 2, 2023, 10:33am UTC](https://janus.discourse.group/t/how-to-access-data-channels-in-janode-when-using-the-videoroom-plugin/539/1 "2023-09-02T10:33:59Z")

</div>

Hey all,  
I have a publisher that is using Janus.js as a client for publishing data in a videoroom. Using janode I can setup the peer connection, access the mediastream track , etc . However I am not able to access anything related to the data coming from the publisher.  
I looked through janode examples and found nothing on data channels.  
It ll be really great help if someone can point me in the right direction for going about this.

P.S I have already tried to listen to data channel events shown below like

```auto
peerConnection.ondatachannel = (event) => {
  const dataChannel = event.channel;

  dataChannel.onopen = () => {
    console.log('Data channel opened');
  };

  dataChannel.onmessage = (event) => {
    console.log('Received message:', event.data);
  };

  dataChannel.onclose = () => {
    console.log('Data channel closed');
  };
};

```

But this doesn’t seem to work.  
I can confirm that data is being sent from the publisher based on console and media server logs.

---

<div class="post-metadata">

**Author:** ![atoppi](https://yyz2.discourse-cdn.com/free1/user_avatar/janus.discourse.group/atoppi/32/8_2.png) [@atoppi](https://janus.discourse.group/u/atoppi)\
**Post date:** [September 4, 2023, 9:11am UTC](https://janus.discourse.group/t/how-to-access-data-channels-in-janode-when-using-the-videoroom-plugin/539/2 "2023-09-04T09:11:57Z")

</div>

please don’t cross post the same request, we have already replied on github

> <https://github.com/meetecho/janode/issues/27>
>
> Hey all,
> I have a publisher that is using Janus.js as a client for publishing d…ata in a videoroom. Using janode I can setup the peer connection, access the mediastream track , etc . However I am not able to access anything related to the data coming from the publisher.
> I looked through janode examples and found nothing on data channels. 
> It ll be really great help if someone can point me in the right direction for going about this.
> 
> P.S I have already tried to listen to data channel events shown below like
> 
> \`\`\`
> peerConnection.ondatachannel = (event) =\> {
> const dataChannel = event.channel;
> 
> dataChannel.onopen = () =\> {
> console.log('Data channel opened');
> };
> 
> dataChannel.onmessage = (event) =\> {
> console.log('Received message:', event.data);
> };
> 
> dataChannel.onclose = () =\> {
> console.log('Data channel closed');
> };
> };
> \`\`\`
> 
> But this doesn't seem to work. 
> I can confirm that data is being sent from the publisher based on console and media server logs.

---

<div class="post-metadata">

**Author:** ![atoppi](https://yyz2.discourse-cdn.com/free1/user_avatar/janus.discourse.group/atoppi/32/8_2.png) [@atoppi](https://janus.discourse.group/u/atoppi)\
**Post date:** [September 29, 2023, 1:36pm UTC](https://janus.discourse.group/t/how-to-access-data-channels-in-janode-when-using-the-videoroom-plugin/539/3 "2023-09-29T13:36:51Z")

</div>

You have to mimic in your RTC stack (using janode) what janus.js does.  
It might sound a bit tricky but you should create a datachannel on the peer side with the default Janus label and also be ready to accept the callback “ondatachannel”.

Check how createDataChannel is used [here](https://github.com/meetecho/janus-gateway/blob/7a76cfe1a27a50b522cd70ff10a71c769dd6c93a/html/janus.js#L2342) and also what operations [it performs](https://github.com/meetecho/janus-gateway/blob/7a76cfe1a27a50b522cd70ff10a71c769dd6c93a/html/janus.js#L1650).
