meetecho / janode

A Node.js adapter for the Janus WebRTC server
ISC License
98 stars 36 forks source link

Unable to access data channels when using Janode with Janus.js client (VideoRoom Plugin) #27

Closed ashkalor closed 1 year ago

ashkalor commented 1 year ago

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

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.

atoppi commented 1 year ago

have you set data: true when either configuring or publishing the participant?

ashkalor commented 1 year ago

Yes, I have done that.

const roomResponse = await videoHandle.joinSubscriber({
          room: process.env.JANUS_ROOM,
          feed: process.env.JANUS_DEVICE_ID + "-data",
          audio: false,
          video: true,
          data: true,
          restart: true,
        });

The only error i do get is in media server, where it says the feed api is deprecated.

I found a work around through which if I manually create the data channel with the same label as incoming data( i.e the feed id ). I am able to receive the data. However when the publisher stops publishing, disconnects or reconnects to Janus server. The subscriber has no way of knowing that the data has stopped. The onclose events on data channel do not fire and the subscribers don't get notification using the videoroom plugin events.

atoppi commented 1 year ago

I meant on the publishing side. BTW datachannels happen on the negotiation (SDP) and janode only acts on the signalling plane (the data: true flag), I don't see how the library could interfere with the data channels setup.

ashkalor commented 1 year ago

Hey , The publisher is sending data, when I create a subscriber using janus.js. I am able to receive the data.

I understand that this library only acts on the signaling plane and maybe isn't affecting the issue at all however since janode is the best fit for usage in node applications. Its integration with Janus.js client on the web will be really beneficial which is also why I put up this question in the general category of the discourse group.

In an ideal scenario, when two peers connect we are able to directly access the data channel, catch the close events etc, but since this is going through janus. I am not sure if I am doing something wrong which is causing the peer connection to not catch the data channel events.

Any help to debug this will be greatly appreciated.

atoppi commented 1 year ago

Closing since I plan to move the discussion to the discourse group.