# WebRTC ingest stream network quality information (Java API)

**URL:** <https://community.wowza.com/t/webrtc-ingest-stream-network-quality-information-java-api/93382>\
**Category:** Wowza Streaming Engine\
**Tags:** webrtc\
**Created:** [June 3, 2021, 11:13am UTC](https://community.wowza.com/t/webrtc-ingest-stream-network-quality-information-java-api/93382 "2021-06-03T11:13:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![robymus](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/robymus/32/784_2.png) [@robymus](https://community.wowza.com/u/robymus)\
**Post date:** [June 3, 2021, 11:13am UTC](https://community.wowza.com/t/webrtc-ingest-stream-network-quality-information-java-api/93382/1 "2021-06-03T11:13:23Z")

</div>

I’m trying to get some statistics/information on the network quality of incoming WebRTC streams, like packets/frames lost, retransmission count, anything that’s available would be helpful.

I’ve discovered (with IDE autocomplete magic) that there is a setLossNotifier method in the WebRTCSession but I couldn’t find any information on how it works or if it’s related to these kind of statistics at all.

Is there an API to gather this or related information?

---

<div class="post-metadata">

**Author:** ![robymus](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/robymus/32/784_2.png) [@robymus](https://community.wowza.com/u/robymus)\
**Post date:** [June 3, 2021, 12:02pm UTC](https://community.wowza.com/t/webrtc-ingest-stream-network-quality-information-java-api/93382/2 "2021-06-03T12:02:50Z")

</div>

I’ve just tried the RTPSession.getIOPerformanceCounter() method, to get some statistics. While the getMessagesInBytes() and getMessagesInCount() (and rates) works as expected in the performance counter, the getMessagesLossCount() and getMessagesLossBytes() methods (and rates) consistently return 0.

---

<div class="post-metadata">

**Author:** ![video\_streaming](https://avatars.discourse-cdn.com/v4/letter/v/22d042/32.png) [@video\_streaming](https://community.wowza.com/u/video_streaming)\
**Post date:** [June 3, 2021, 7:33pm UTC](https://community.wowza.com/t/webrtc-ingest-stream-network-quality-information-java-api/93382/3 "2021-06-03T19:33:45Z")

</div>

Once you have ‘enable webrtc queries’ enabled in Streaming Engine, these are the java method calls to query only webRTC streams. The query check box on engine manager allows you to send the queryAll message over the websocket to an application

```
List<RTPSession> getWebRTCSessions()
List<RTPSession> getWebRTCSessions(String streamName)
int getWebRTCSessionCount()
int getWebRTCSessionCount(String streamName)
Map<String, Integer> getWebRTCSessionCountsByName()

```

Once you have that info, you can make normal REST API queries to get stream stats as you were asking about:

[https://www.wowza.com/docs/statistics-query-examples](https://www.wowza.com/docs/statistics-query-examples)

---

<div class="post-metadata">

**Author:** ![robymus](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/robymus/32/784_2.png) [@robymus](https://community.wowza.com/u/robymus)\
**Post date:** [June 4, 2021, 9:08am UTC](https://community.wowza.com/t/webrtc-ingest-stream-network-quality-information-java-api/93382/4 "2021-06-04T09:08:32Z")

</div>

This is not exactly what I’m looking for. The REST API linked (incomingstreams) only reports bytes in/out and byterate in/out. This information is also available from RTPSession.getIOPerformanceCounter() Java API, but what I’m looking for is some kind of quality feedback, like number of packages lost (NACK sent), frames missing, or similar.

We are having quality degradations on streams published at higher quality than resources allowed and we’d like to try and detect it. Detection on the publishing (browser) side is not totally reliable, although covers some of the cases. A network level quality feedback would be very useful for our current usecase.

---

<div class="post-metadata">

**Author:** ![Rose\_Power-Wowza\_Com](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/rose_power-wowza_com/32/431_2.png) [@Rose\_Power-Wowza\_Com](https://community.wowza.com/u/Rose_Power-Wowza_Com)\
**Post date:** [June 4, 2021, 9:43pm UTC](https://community.wowza.com/t/webrtc-ingest-stream-network-quality-information-java-api/93382/5 "2021-06-04T21:43:33Z")

</div>

I see and can understand the need for that. I did check with tech support to confirm for you and this is what I was told:

"There is this property (logPacketLoss)

> **[Set up WebRTC streaming with Wowza Streaming Engine](https://www.wowza.com/docs/how-to-use-webrtc-with-wowza-streaming-engine#configure-a-live-application)**
>
> Learn how to stream WebRTC with Wowza Streaming Engine.

How to capture that with the Java API, we do not have examples for them for this. They might need to set that logging and see if they can reverse engineer how it’s created. Or work with our ProServ Team to build out a solution for his packet loss handling needs."

I can add it as a feature request for you with the Engine team. We also have a very advanced group of webrtc developers from around the world in our slack channel if you want to ask in there if anyone has a way to capture that.

You can join here and it’s just the #webrtc channel

> **[The Wowza "LiveStreaming" Slack Group](https://www.wowza.com/community/t/the-wowza-livestreaming-slack-group/95725)**
>
> Greetings and welcome to the Wowza Forums! You may be wondering what happened to the Wowza “LiveStreaming” Slack Group, at the end of 2022 the decision was made to retire that medium and consolidate all of the insightful information and great...

---

<div class="post-metadata">

**Author:** ![robymus](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/robymus/32/784_2.png) [@robymus](https://community.wowza.com/u/robymus)\
**Post date:** [June 5, 2021, 3:17am UTC](https://community.wowza.com/t/webrtc-ingest-stream-network-quality-information-java-api/93382/6 "2021-06-05T03:17:39Z")

</div>

Looks like I’ve overlooked the logPacketLoss flag. So here is my evaluation result: setting logPacketLoss=true and useNack=true (with useNack=false nothing happens), I see some activity.

First there are WARN entries in the Wowza log:

```nohighlight
WARN server comment - JitterBuffer.packetLoss[s/_definst_/publish-1c945e43-553f-4545-b79f-a1776e1a6336]: last sent sequence number:15819 current sequence number:15850, diff: 30

```

And also the lossNotification event (set be `WebRTCSession.setLossNotifier()` will get invoked. I also have to call the `WebRTCSession.setLossNotifierInterval()` which takes a long parameter, which is not milliseconds, but it is correlated with the frequency of the notifier being invoked - setting to 100 will gave a 1-6 sec time between notification, maybe it’s related to loss packet/byte count? (I’m simulating a 25% packet loss on the network for quick testing)

The interesting thing is the parameters of the `IWebRTCLossNotifier.onLossNotification(long l, double v, WebRTCSession webRTCSession)` method invoked: the l parameter is most likely the total diff in sequence numbers on the track with highest total diff (based on the diff fields in the log, see below), the v parameter is strange, I have no clue what it could be 🙂

The interesting thing is that if I use the `WebRTCSession.setLossNotifier()` method, the RTPSession’s IOPerformanceCounter reports 0 for InBytes and InCount metrics. The LossCount and LossBytes metrics are always zero, even with logPacketLoss set to true and no loss notifier set.

Here is a log excerpt, on what i see:

```nohighlight
WARN server comment - JitterBuffer.packetLoss[s/_definst_/publish-1c945e43-553f-4545-b79f-a1776e1a6336]: last sent sequence number:34617 current sequence number:34641, diff: 23
WARN server comment - JitterBuffer.packetLoss[s/_definst_/publish-1c945e43-553f-4545-b79f-a1776e1a6336]: last sent sequence number:34641 current sequence number:34658, diff: 16
WARN server comment - JitterBuffer.packetLoss[s/_definst_/publish-1c945e43-553f-4545-b79f-a1776e1a6336]: last sent sequence number:15193 current sequence number:15195, diff: 1
2021-06-05 09:59:51 (INFO) onLossNotification l=39 v=164375.0
WARN server comment - JitterBuffer.packetLoss[s/_definst_/publish-1c945e43-553f-4545-b79f-a1776e1a6336]: last sent sequence number:34864 current sequence number:35034, diff: 169
WARN server comment - JitterBuffer.packetLoss[s/_definst_/publish-1c945e43-553f-4545-b79f-a1776e1a6336]: last sent sequence number:15257 current sequence number:15324, diff: 66
2021-06-05 09:59:51 (INFO) onLossNotification l=169 v=167689.0
WARN server comment - JitterBuffer.packetLoss[s/_definst_/publish-1c945e43-553f-4545-b79f-a1776e1a6336]: last sent sequence number:35814 current sequence number:35911, diff: 96
WARN server comment - JitterBuffer.packetLoss[s/_definst_/publish-1c945e43-553f-4545-b79f-a1776e1a6336]: last sent sequence number:15558 current sequence number:15595, diff: 36
2021-06-05 09:59:57 (INFO) onLossNotification l=96 v=206233.0
WARN server comment - JitterBuffer.packetLoss[s/_definst_/publish-1c945e43-553f-4545-b79f-a1776e1a6336]: last sent sequence number:36635 current sequence number:36642, diff: 6
WARN server comment - JitterBuffer.packetLoss[s/_definst_/publish-1c945e43-553f-4545-b79f-a1776e1a6336]: last sent sequence number:36642 current sequence number:36790, diff: 147
WARN server comment - JitterBuffer.packetLoss[s/_definst_/publish-1c945e43-553f-4545-b79f-a1776e1a6336]: last sent sequence number:15819 current sequence number:15850, diff: 30
2021-06-05 10:00:03 (INFO) onLossNotification l=153 v=117893.0

```

Anyway, this is getting close to what I’m looking for, I practically have the number of lost packets, but knowing the total number of packets would also be important, but unfortunately it is lost, as soon as I set a loss notifier… I join the slack channel you suggested and try to pursue more information on the subject.

---

<div class="post-metadata">

**Author:** ![Remy\_G](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/remy_g/32/487_2.png) [@Remy\_G](https://community.wowza.com/u/Remy_G)\
**Post date:** [June 5, 2021, 7:54am UTC](https://community.wowza.com/t/webrtc-ingest-stream-network-quality-information-java-api/93382/7 "2021-06-05T07:54:38Z")

</div>

Best way to capture this is where it happens: in the browser. Using WebRTC’s getStats you can collect any metric you like, such as Nack count, packet loss, bitrate etc.

What we do is simply collect all of this during a stream and feed it into our logging/monitoring system.

During a WebRTC session, access in your Chrome browser: chrome://webrtc-internals  
These are all the metrics available and you can capture this via the getStats() API in Javascript.

---

<div class="post-metadata">

**Author:** ![Rose\_Power-Wowza\_Com](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/rose_power-wowza_com/32/431_2.png) [@Rose\_Power-Wowza\_Com](https://community.wowza.com/u/Rose_Power-Wowza_Com)\
**Post date:** [June 5, 2021, 3:51pm UTC](https://community.wowza.com/t/webrtc-ingest-stream-network-quality-information-java-api/93382/8 "2021-06-05T15:51:52Z")

</div>

Thanks so much Remy. @robymus Remy is one of the [webrtc experts](http://community.wowza.com/t/streaming-expert-spotlight-remy-gardien/92018) I was referring to who is typically more available in our slack channel.
