# Handling err/warns

**URL:** <https://mediasoup.discourse.group/t/handling-err-warns/1219>\
**Category:** mediasoup libraries\
**Created:** [June 8, 2020, 5:43am UTC](https://mediasoup.discourse.group/t/handling-err-warns/1219 "2020-06-08T05:43:30Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![OG-RTC](https://avatars.discourse-cdn.com/v4/letter/o/f475e1/32.png) [@OG-RTC](https://mediasoup.discourse.group/u/OG-RTC)\
**Post date:** [June 8, 2020, 5:43am UTC](https://mediasoup.discourse.group/t/handling-err-warns/1219/1 "2020-06-08T05:43:31Z")

</div>

Hello,  
I would like to add on top of my mediasoup server some logic to do handle errors correctly. For instance detect poor connections, frequent disconnects, incompatibility issues between client/server etc. Can anyone point me to some documentation to do that? The documentation is huge and need some guidance on where to look  
Thanks

---

<div class="post-metadata">

**Author:** ![aetheon](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/aetheon/32/39_2.png) [@aetheon](https://mediasoup.discourse.group/u/aetheon)\
**Post date:** [June 8, 2020, 7:16am UTC](https://mediasoup.discourse.group/t/handling-err-warns/1219/2 "2020-06-08T07:16:38Z")

</div>

My experience with doing something similar by calling transport getStats in an interval server side was a failure because the node process quickly escalated in CPU usage. I don’t recommend doing this kind of thing in the same node process.

---

<div class="post-metadata">

**Author:** ![OG-RTC](https://avatars.discourse-cdn.com/v4/letter/o/f475e1/32.png) [@OG-RTC](https://mediasoup.discourse.group/u/OG-RTC)\
**Post date:** [June 8, 2020, 7:19am UTC](https://mediasoup.discourse.group/t/handling-err-warns/1219/3 "2020-06-08T07:19:40Z")

</div>

Any other recommendation?

---

<div class="post-metadata">

**Author:** ![aetheon](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/aetheon/32/39_2.png) [@aetheon](https://mediasoup.discourse.group/u/aetheon)\
**Post date:** [June 8, 2020, 7:35am UTC](https://mediasoup.discourse.group/t/handling-err-warns/1219/4 "2020-06-08T07:35:19Z")

</div>

You can have a different architecture server-side, if you wanna use do that 100% server side.

The other way is using client-side to process the getStats results from mediasoup using the WS or HTTP.  
You can also use client-side [RTCRtpSender/getStats](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpSender/getStats). Be aware that this dictionary is different in FF, Chrome and Safari so you might not have access to some data.

This is a difficult issue because if a participant video is slow it doesn’t mean you have a poor connection, it could be the participant upload, mediasoup server lag, geographic link lag for upload/download, …

Other than these comments I’m afraid I have no more knowledge to share ☹ Would love to hear other people on this subject.

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [June 8, 2020, 7:57am UTC](https://mediasoup.discourse.group/t/handling-err-warns/1219/5 "2020-06-08T07:57:02Z")

</div>

Too many topics together here.

- WebRTC disconnections are better handled/monitored at client level by listening for the `transport.on('connectionstatechange')` event. When ‘disconnected’ happens it means temporary bad connection. It may reconnected automatically (‘connected’/‘completed’ is fired again).

- “Incompatibility issues between client/server”: I don’t know what this means and this is not something related to mediasoup but to your app.

- “Poor connection”: Too vague concept. For media senders you can listen to `producer.on('score')` events in mediasoup `Producer`.

---

<div class="post-metadata">

**Author:** ![OG-RTC](https://avatars.discourse-cdn.com/v4/letter/o/f475e1/32.png) [@OG-RTC](https://mediasoup.discourse.group/u/OG-RTC)\
**Post date:** [June 8, 2020, 10:34am UTC](https://mediasoup.discourse.group/t/handling-err-warns/1219/6 "2020-06-08T10:34:04Z")

</div>

How about the observers? Any special one I should look into to detect unreliable connections and report back the exact problem in order to find an appropriate mitigation? Idea is to spot all kinds of problems and find some workarounds for them

---

<div class="post-metadata">

**Author:** ![brunton\_doug](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/brunton_doug/32/446_2.png) [@brunton\_doug](https://mediasoup.discourse.group/u/brunton_doug)\
**Post date:** [June 8, 2020, 9:27pm UTC](https://mediasoup.discourse.group/t/handling-err-warns/1219/8 "2020-06-08T21:27:48Z")

</div>

It seems like you’re looking for a simple answer to a wide reaching topic. Even “unstable connection” can have many meanings - for example the transport connection state could be flapping, there could be packet loss on the connection, latency could be high, there could be lots of jitter, your signaling service could be timing out, the client encoder might downgrade quality because of network or CPU usage, etc.

I think your best bet is to dig deep into the documentation, and log some telemetry data (producer scores, stats from the client and server, connectionstatechange events, etc) while you do reproducible qualitative tests.

You might also want to look into simulcast, as trying to force more bits over a wire than it supports can be the cause of connection instability, and bandwidth estimation based layer changes can help you, there.

[edit: sorry for the deletion above, I wanted to thread this post correctly]

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [June 15, 2020, 8:43am UTC](https://mediasoup.discourse.group/t/handling-err-warns/1219/10 "2020-06-15T08:43:12Z")

</div>

> [@OG-RTC](#):
>
> Can you please advise how would you do the inter-process node communication in this case? I prefer not having the mediasoup media process being affected by the media soup stats

I don’t understand the question. There are no stats involved in the Producer/Consumer `score` events.

---

<div class="post-metadata">

**Author:** ![OG-RTC](https://avatars.discourse-cdn.com/v4/letter/o/f475e1/32.png) [@OG-RTC](https://mediasoup.discourse.group/u/OG-RTC)\
**Post date:** [June 15, 2020, 9:28am UTC](https://mediasoup.discourse.group/t/handling-err-warns/1219/11 "2020-06-15T09:28:20Z")

</div>

Reordering my reply to the correct thread:

Hello, Can you please advise how would you do the inter-process node communication in this case? I prefer not having the mediasoup media process being affected by the media soup stats  
thanks

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [June 15, 2020, 4:14pm UTC](https://mediasoup.discourse.group/t/handling-err-warns/1219/12 "2020-06-15T16:14:45Z")

</div>

I’ve already replied to that.
