Can't receive either video or audio track (only sometimes)

Hi,
Now I am testing lib-jitsi-meet apis with self-host jitsi server.

After I joined Jitsi conference, I added tracks.

this.jitsiRoom.on(
this.JitsiMeetJS.events.conference.CONFERENCE_JOINED,
async () => { await this.onJitsiConferenceJoined(); });
);
this.jitsiRoom.join()

async onJitsiConferenceJoined() {
        for (let i = 0; i < this.localTracks.length; i++) {
            this.Log("[ OUT ] my track - " + this.localTracks[i].getType());
            await this.jitsiRoom.addTrack(this.localTracks[i]).catch((error: any) => {
                this.Log(error);
            });
 }

This works sometimes but sometimes, it only send audio or video track.
I confirmed it by these codes.

  this.jitsiRoom.on(this.JitsiMeetJS.events.conference.TRACK_ADDED, async (track: any) => {
        await this.onAddedRemoteTrack(track);
    });
    this.jitsiRoom.on(this.JitsiMeetJS.events.conference.TRACK_REMOVED, async (track: any) => {
        await this.onRemovedRemoteTrack(track);
    });

async onAddedRemoteTrack(track: JitsiTrack) {
if (track.isLocal()) {
return;
}
this.Log([ IN ] remote track - ${track.getType()});
}

async onRemovedRemoteTrack(track: JitsiTrack) {
this.Log("[ DEL ] remotetrack - " + track.getType());
}

And the result is
meetinglog2

mlog001

Here user B(later) sends both audio/video track, but user A(former) only received video track.
So I can’t hear user B’s voice.
Vice versa, sometimes I can only receive audio and not video.

But sometimes i can receive both when I load page as refresh.

I wonder I missed some procedure of sending tracks.

I think this is not server error, but my fault. So please give me ways.
Because this error is not always happening and only “sometimes”, so I really can’t find the situation and reason.

I really need jitsi veteran’s experience.

Though I didn’t go through all the things you have done as I worked with lib-jitsi-meet → self hosted server around years ago. Have you looked/tried the JS file from the official documentation ?
If not, you should definitely try to run this first with minimal changes just to work with your setup and then start tweaking other parts or setup more monitoring to understand and develop better.

Hi, sir
Thank you for your reply.

The url that sent me was just the starting point of me.

I forked from lib-jitsi-meet/example.js at master · jitsi/lib-jitsi-meet · GitHub
and only changed to typescript version.

After struggling for some days, I found why this bug happens.

            What I was wrong ( I added tracks after join room)
onJitsiConferenceJoined()  {
    for (let i = 0; i < this.localTracks.length; i++) {
        this.Log("[ OUT ] my track - " + this.localTracks[i].getType());
        this.jitsiRoom.addTrack(this.localTracks[i]);
   }
}
            Now working one (added tracks before join room)
    for (let i = 0; i < this.localTracks.length; i++) {
        this.Log("[ OUT ] my track - " + this.localTracks[i].getType());
        this.jitsiRoom.addTrack(this.localTracks[i]);
   }
   this.jitsiRoom.join()

The solution was to add tracks before join room.

But I can’t explain what is happening in low-level in both cases.

Can you please explain this?