Observer events and know if producers or consumers closed abruptly

Hi,
So I was trying to wrap my head around the question that do producers or consumers be disconnected/closed for whatever reasons even if the concerned transport is connected ?
Looking into observer events we have,

Now in Producer.ts and Consumers.ts in mediasoup-client and same for the mediasoup server side,
I could see these events emitted on either close() or transportClosed() for producers/consumers, which we already have control over or related events (transpportclose) are already subscribed to. So I am assuming that there isn’t any other case where these observer events would be emitted. Hence no way to know for an abrupt closure using observer events.

I am trying to figure out if

  1. Producers/Consumers will be closed without any events emitted (like an exception or failure) with the transport still connected ?
  2. If such a scenario is possible how would we possibly know that the producer/consumer is alive even with a ping/pong mechanism between client server to know the status of the concerned producer/consumer ?

Thanks

No. Once a Producer/Consumer is created they will emit a “xxxxxclose” event if they are closed due to their parent Transport closure (or “produceclose” in Consumer in case its associated Producer is closed).

BTW observers ar eintended for 3rd party libraries that do NOT call mediasoup API methods. In your app core logic you should not use observers (in theory). If you call producer.close() you know that you are closing it so no need for an event telling you “hey you have closed this”. However the Producer observer will always emit “close” no matter how it was closed.

Thanks for the reply.

However the Producer observer will always emit “close” no matter how it was closed.

Will a producer/consumer be closed in any other circumstances even if their parent “transportclose” never occurs ( or “producerclose” never occurs in case of a consumer) ?
(trying to understand if the observer will emit close in such cases and be used to know produce/consumer closure).

I promise that the API documentation specifies all the cases in which xxxxx.observer.on('close') is emitted.

Sorry and I apologize if I am being repetitive here.
Here is my point of confusion (taking consumer as reference).

  1. consumer.observer.on(“close”, fn()) Emitted when the consumer is closed for whatever reason
  2. in mediasoup-client code, I can see this._observer.safeEmit(‘close’); from closed() (calling consumer.close()) and transportClosed()
  3. I could not find any other cases where the close event would be emitted or if I have missed it somewhere in the documentation.

I promise that the API documentation specifies all the cases in which xxxxx.observer.on('close') is emitted.

  1. If so, I am not sure if I follow what all the cases mean or where do I find them in the documentation.

By definition a Consumer is closed when its associated Producer is closed (for whatever reason). So when the Producer is closed, the Consumer will emit producerclose event and its observer will emit close.