Hello! I feel a bit odd that I hadn’t noticed this before, but I seem to be unable to assign the event handlers to the dataProducer after creating it with produceData – mediasoup :: API
After calling produceData, I am returned a dataProducer object. I believe I should be able to call dataProducer.on("open", () => { console.log("Data channel opened!") })
and have the listener setup, but it doesn’t seem to be logging to console.
This is my code below, and it seems like this would work for me. I feel that the events do indeed fire, but I am assigning the listeners after they fire, thus my log doesn’t get called. Also I considered if the ordered: true/false mattered, it doesn’t seem to. I do hope these events being fired do not depend on tcp being the transport. Not sure that would be related, but this transport is going over udp by default.
.produceData({
ordered: false,
maxPacketLifeTime: 50,
label: "SomeChannel",
appData: { source: "someAppDataString" }
})
.then(producer => {
producer.on("open", () => {
console.log("Movement producer open");
});
producer.on("error", error => {
console.error("Movement producer error", error);
});
producer.on("close", () => {
console.log("Movement producer closed");
});
})
.catch(error => {
console.error("Producing movement failed!", error);
});
I have also exposed the dataproducer globally, and called .close() on it. The “movement producer closed” message does not log.
I hope I’m just doing something silly, although I am assuming that the second function argument is just missing from the doc. I imagine it would read dataProducer.on(“open”, fn()); mediasoup :: API
I do get the debug log for the unrelated dataConsumers opening, but not the dataProducer opening. Is it possible that the events do not fire on the producer by design?
Any insights would be appreciated.