# stream view count using Java API

**URL:** <https://community.wowza.com/t/stream-view-count-using-java-api/54691>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api, java\
**Created:** [February 20, 2020, 7:32pm UTC](https://community.wowza.com/t/stream-view-count-using-java-api/54691 "2020-02-20T19:32:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ss\_cx](https://avatars.discourse-cdn.com/v4/letter/s/b19c9b/32.png) [@ss\_cx](https://community.wowza.com/u/ss_cx)\
**Post date:** [February 20, 2020, 7:32pm UTC](https://community.wowza.com/t/stream-view-count-using-java-api/54691/1 "2020-02-20T19:32:44Z")

</div>

What is the best way to get the current view count for an IMediaStream using the Java API? I was going to use getHTTPStreamerSessionCountsByName

but even doing appInstance.getHTTPStreamerSessionCount()

returns 0 even though I know there are HTTP connections on the app instance and stream (because I am the one connecting).

---

<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:** [February 20, 2020, 7:39pm UTC](https://community.wowza.com/t/stream-view-count-using-java-api/54691/2 "2020-02-20T19:39:55Z")

</div>

I was looking for your other post to answer, but I think it’s no longer active? I did get an answer from the engineers and this what they’d like me to share:

`getConnectionCounter()` = maximum number of streams that can be published to the server

`getHTTPStreamerSessionCount()` = number of HTTP Streams associated with an app instance

* * *

They suggest you call this:

```auto
int getHTTPStreamerSessionCount(int protocol);

```

and pass it:

```auto
IHTTPStreamerSession.SESSIONPROTOCOL_CUPERTINOSTREAMING

```

For example:

```auto
int hlsCount = getHTTPStreamerSessionCount(IHTTPStreamerSession.SESSIONPROTOCOL_CUPERTINOSTREAMING);

```

Let me know if that helps you @ss cx

---

<div class="post-metadata">

**Author:** ![ss\_cx](https://avatars.discourse-cdn.com/v4/letter/s/b19c9b/32.png) [@ss\_cx](https://community.wowza.com/u/ss_cx)\
**Post date:** [February 21, 2020, 4:45pm UTC](https://community.wowza.com/t/stream-view-count-using-java-api/54691/3 "2020-02-21T16:45:29Z")

</div>

getHTTPStreamerSessionCount() always returns 0 even though the stream has viewers (me). Do you have any ideas for other considerations that could be causing this?

---

<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:** [February 21, 2020, 4:50pm UTC](https://community.wowza.com/t/stream-view-count-using-java-api/54691/4 "2020-02-21T16:50:18Z")

</div>

We don’t and I showed your post to the engineers too. Rather than us guessing and you not getting a resolution, can you submit a support ticket and then tech support can view all the config files/ logs, run some tests and quickly identify the issue for you.

We can get this resolved very quickly through a ticket. It just gives us more access to your files and we can try and replicate what you are seeing. Thanks @ss cx.

[https://www.wowza.com/support/open-ticket](https://www.wowza.com/support/open-ticket)

---

<div class="post-metadata">

**Author:** ![ss\_cx](https://avatars.discourse-cdn.com/v4/letter/s/b19c9b/32.png) [@ss\_cx](https://community.wowza.com/u/ss_cx)\
**Post date:** [February 24, 2020, 7:01pm UTC](https://community.wowza.com/t/stream-view-count-using-java-api/54691/5 "2020-02-24T19:01:54Z")

</div>

Hi Rose, thank you for your help! It turns out the mistake was on my part because the connection sessions in my case were WebSocketSessions, rather than HTTP Sessions.

Thus, a follow-up question: Is there a way to get the session count by stream name and protocol for WebSocketSessions, as is possible for HTTPStreamerSessions?

Thank you again!

---

<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:** [February 24, 2020, 7:03pm UTC](https://community.wowza.com/t/stream-view-count-using-java-api/54691/6 "2020-02-24T19:03:59Z")

</div>

Happy to check for you…

---

<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:** [February 24, 2020, 8:40pm UTC](https://community.wowza.com/t/stream-view-count-using-java-api/54691/7 "2020-02-24T20:40:59Z")

</div>

If you’re trying to do this through webrtc, then you can use this:

this.applicationInstance.getWebRTCSessionCount();
