Wowza Community

stream view count using Java API

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).

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:

int getHTTPStreamerSessionCount(int protocol);

and pass it:

IHTTPStreamerSession.SESSIONPROTOCOL_CUPERTINOSTREAMING

For example:

int hlsCount = getHTTPStreamerSessionCount(IHTTPStreamerSession.SESSIONPROTOCOL_CUPERTINOSTREAMING);

Let me know if that helps you @ss cx

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

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

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!

Happy to check for you…

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

this.applicationInstance.getWebRTCSessionCount();