Hi, I have encountered an issue with my code, let me explain the first one: I connect to the server in 2 different clients, but only the second client can actually consume, when I add a third client, only the third client can consume. Also, when I have only 1 client, the client can’t consume itself. Here are my debug logs:
Screenshot 2021-09-21 at 17.22.35|690x140
Code:
let consumers = [];
// eslint-disable-next-line prefer-const
let localconsumers = [];
for (const i in producers) {
const producer = producers[i];
console.log(`[${consumerTransport.id}]: ${producer.id} ${router.canConsume({producerId: producer.id, rtpCapabilities}) ? "can" : "can't"} be consumed`)
if (router.canConsume({
producerId: producer.id,
rtpCapabilities
})) {
const consumer = await consumerTransport.consume({
producerId: producer.id,
rtpCapabilities,
paused: false,
});
localconsumers.push(consumer);
console.log("[INFO] Pushing", consumer.id);
consumers.push({
producerId: producer.id,
id: consumer.id,
kind: producer.kind,
rtpParameters: consumer.rtpParameters
});
}
}
socket.emit("transportConsume", consumers);
return localconsumers;
It doesn’t seem to throw any errors.
SOLVED
The second issue:
The second client gets the okay to consume from the server, but then throws
Uncaught (in promise) UnsupportedError: cannot consume this Producer
Code:
data.forEach(async (prod) => {
const consumer = await this.consumerTransport.consume(prod);
await this.createvid(await this.streame(consumer), prod.id);
this.consumers.push(consumer);
});