Error 429 missing mandatory 'feed' as a subscriber to a room

Hi all,

In my videoroom I’m having publishing working. But when I want to join-only, I want to subscribe to a room and get the list of publishers. However; When I subscribe to a room, I get ‘Joined room a subscriber’ which means this worked. But immediately after in my onmessage, I receive that I’m missing mandatory field ‘feed’.

I’m expecting to get a list with the publishers so I can actually subscribe to their specific feeds, but it never gets to that point. My code is pretty clear I think;

this.janus.attach({
              plugin: 'janus.plugin.videoroom',
              success: (pluginHandle: any) => {
                pluginHandle.send({
                    message: {
                        request: 'join',
                        room: roomId,
                        ptype: 'subscriber',
                    },
                    success: () => {
                        console.log('Joined room as subscriber:', roomId);
                        resolve(roomId);
                    },
                    error: (error: any) => {
                        console.error('Error joining room as subscriber:', error);
                        reject(error);
                    },
                    onmessage: (msg: any, jsep: any) => {
                        console.log("MSG", msg);
                        if (msg['publishers']) {
                            msg['publishers'].forEach((publisher: any) => {
                                console.log(publisher);
                                this.subscribeToPublisher(publisher.id, roomId);
                            });
                        }
                    },
                });

                resolve(roomId);
              },
              error: (error: string) => {
                console.error(`Error attaching to the room ${roomId}`, error);
                reject(error);
              },
            });

I’m using the latest npm packages of Janus-gateway and Webrtc-adapter.

1 Like

As explained in the documentation, if you want a list of participants and know who joins/leaves, you need a publisher handle even if you only want to subscribe. A publisher handle doesn’t mean you’ll publish, it’s only used for signalling in that case. Please refer to the documentation for more details and explanations.

1 Like

Thanks, this indeed works and gets me one step further.
Now a question; If I join the room I create a handle, then I receive the list of participants.
If I want to subscribe to their feeds, should I create a seperate handle for every participant?
Because otherwise when I use this:

const subscribe = {
      room: roomId,
      ptype: 'subscriber',
      request: 'join',
      streams: [{ feed_id: feed_id }],
  };

It tells me that I’m “already in as a publisher on this handle”.
Whats the best practice on this?
I’m pretty close right now, but I want to do it the correct way.

The documentation explains that too. You either create a separate handle for every feed (old approach, what 0.x did and does), or you put them in the same subscription handle using the subscribe/update request (multistream approach), in bulk the first time, and then any time new people join.

Hi Lorenzo! Thank you for the quick reply.
I am reading the docs and already tried subscribe / update as the ‘request’ but I get error_code 423: “Unknown request ‘subscribe’” or ‘update’ if I try these.

Is this a server side issue?

Are you using Janus 1.x or 0.x? subscribe is a 1.x request. Make sure you’re sending it on the subscriber handle, not the publisher one.

I’m using 1.x but Im first joining a room as publisher. So after that I always still have to create a new handle for every publisher?
Because if I create a new handle with just ‘update’ it doesnt work. And if I use the old handle, it doesnt works because that handle is a publisher.

Is the correct flow;

  • handle 1: join as publisher
  • handle 2: join publisher feed as ‘subscriber’
  • handle 2: send subscribe or update request?

Not sure what you mean in point 2 by “join publisher feed as ‘subscriber’”, but my guess is that your source of confusion is there. You’re right that you only need to use two handles, yes: one publisher (just for events on available publishers, in your case), and another for all subscriptions. The first time you create the subscriber handle, you tell it to subscribe to all the feeds you know (not your own publisher feed, since you’re not even published); after that, you use subscribe/unsubscribe/update rquests to change that subscription as publishers come and go. Please refer to the multistream VideoRoom demo for more details on how that’s done in practice.