Wowza Community

stream.getHTTPStreamerSession().getSessionId() null in custom IRandomAccessReader

Hi.

We are using a static Map in application scope to store objects based on session ids for http streaming sessions. This is done in

onHTTPSessionCreate(IHTTPStreamerSession httpSession) 

method.

In addition to that we have implemented a custom IRandomAccessReader which makes use of objects in that map. Running tests on local developpement machine as well as load tests using curl in bash scripts work great. However on live system under load of iOS devices we can see, that inside

public void init(IApplicationInstance appInstance, IMediaStream stream, String basePath, String mediaName, String mediaExtension) {

calling

stream.getHTTPStreamerSession().getSessionId()

is null sometimes (not always!) , leading to NPE in following code.

We are using Wowza Server 3.6.2. The question is, why is sessionId missing sometimes, whereas p.ex.

stream.getHTTPStreamerSession().getQueryStr()

is never null.

Thanks in advance,

Sascha

Hello Sascha,

It may be that you are seeing an initial request from the hls player albeit it should contain information regarding the session ID. To test this, setup a simple module and printout the session id. If you are later looking for the ID (Through another event/process) and it isn’t available, it may be more of a lifespan issue of the given session.

Thanks,

Matt

Hi,

A couple of things it could be

I - it is not a http client connecting all the time. If a rtmp/rtsp client then you should check that too.

II - there is a possibility that the hook is being called outside of a client connection.

I suspect gethttpstreamersession is null in your code, from your description which suggests further debugging from your side is needed.

Andrew

Hi.

Yes, as I tried to explain, sessionID is perfectly available inside a module’s methods onHTTPSessionCreate/onHTTPSessionDestroy and “sometimes” also inside the RandomFileAccessReaders init() method, but not always. Since we need sessionID in Reader class to access sesion related stuff this is a problem.

So Yes, this seems to be a session lifecycle issue inside Wowza. Wowza seems to loose session ID somewhere (when iOS client requests next chunk?, when user seeks?) or iOS client (we are talking about a native iOS app as client) seems not to send sessionID all the time?

Currently we have a huge production issue because of this strange behaviour so any help is appreciated…

Best regards,

Sasscha

Hi Andrew,

I - we use iOS client only and control the stream links. Only HLS ist used

II - custom reader is used via “randomAccessReaderClass” in application.xml. Why would Wowza initialize a reader object outside a client connection?

III - stream.getHTTPStreamerSession() is NOT null as I can perfectly call stream.getHTTPStreamerSession().getQueryStr(); and get a valig query. ONLY stream.getHTTPStreamerSession().getSessionID() is null

Thanks,

Sascha

Some more information after having extended logging:

Problem seems to appear on iOS 6 clients only. iOS7 and even iOS5 clients always have sessionID in init() method of RandomAccesReader.

2014-02-03	11:08:22	MEZ	comment	server	ERROR	500	-	----------------- Session ID is null -----------------------------	-	-	-	7.266	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-
2014-02-03	11:08:22	MEZ	comment	server	ERROR	500	-	Query String: userId=27312&contentId=211254&endtime=1392591600&hash=50ba172c7ce7bc4893cb46c856582eb5	-	-	-	7.267	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-
2014-02-03	11:08:22	MEZ	comment	server	ERROR	500	-	User Agent: AppleCoreMedia/1.0.0.10B329 (iPhone; U; CPU OS 6_1_3 like Mac OS X; de_de)	-	-	-	7.267	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-
2014-02-03	11:08:22	MEZ	comment	server	ERROR	500	-	HTTP HEADERS: {protocol=HTTP/1.1, connection=keep-alive, host=85.25.98.25:1935, accept-language=de-de, range=bytes=0-1, accept=*/*, context=onleihe/mp3:001.mp3c/playlist.m3u8?userId=27312&contentId=211254&endtime=1392591600&hash=50ba172c7ce7bc4893cb46c856582eb5, method=GET, user-agent=AppleCoreMedia/1.0.0.10B329 (iPhone; U; CPU OS 6_1_3 like Mac OS X; de_de), accept-encoding=identity, x-playback-session-id=1127969C-00F4-4827-9925-F4CB67372266, uri=GET /onleihe/mp3:001.mp3c/playlist.m3u8?userId=27312&contentId=211254&endtime=1392591600&hash=50ba172c7ce7bc4893cb46c856582eb5 HTTP/1.1}	-	-	-	7.268	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-
2014-02-03	11:08:22	MEZ	comment	server	ERROR	500	-	isAcceptSession() : true	-	-	-	7.268	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-
2014-02-03	11:08:22	MEZ	comment	server	ERROR	500	-	isHTTPOrigin() : false	-	-	-	7.268	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-
2014-02-03	11:08:22	MEZ	comment	server	ERROR	500	-	isValidated() : false	-	-	-	7.269	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-
2014-02-03	11:08:22	MEZ	comment	server	ERROR	500	-	------------------------------------------------------------------	-	-	-	7.269	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-

java.lang.NullPointerException
	at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:917)
	at com.etecture.divibib.onleihe.ShufflerPool.getShuffler(ShufflerPool.java:40)
	at com.etecture.divibib.onleihe.ExperimentalWatermarkFileShufflingReader.init(ExperimentalWatermarkFileShufflingReader.java:81)
	at com.wowza.io.RandomAccessReaderFactory.createInstance(RandomAccessReaderFactory.java:20)
	at com.wowza.wms.mediareader.mp3.MediaReaderMP3.init(MediaReaderMP3.java:135)
	at com.wowza.wms.httpstreamer.model.HTTPStreamerAdapterBase.doesFileExist(HTTPStreamerAdapterBase.java:1418)
	at com.wowza.wms.httpstreamer.cupertinostreaming.httpstreamer.HTTPStreamerAdapterCupertinoStreamer.onCheckAvailability(HTTPStreamerAdapterCupertinoStreamer.java:545)
	at com.wowza.wms.httpstreamer.cupertinostreaming.httpstreamer.HTTPStreamerAdapterCupertinoStreamer.serviceMsg(HTTPStreamerAdapterCupertinoStreamer.java:432)
	at com.wowza.wms.httpstreamer.cupertinostreaming.httpstreamer.HTTPStreamerAdapterCupertinoStreamer.service(HTTPStreamerAdapterCupertinoStreamer.java:393)

As you can see on stacktrace, init() is called from:

com.wowza.wms.httpstreamer.model.HTTPStreamerAdapterBase.doesFileExist(HTTPStreamerAdapterBase.java:1418)

To eventually implement a workaround for iOS 6 clients I need to know: Is the Reader which is initialized inside com.wowza.wms.httpstreamer.model.HTTPStreamerAdapterBase.doesFileExist reused for Reading or is another reader object initialized for streaming afterwards (which maybe has valid sessionID) ?

Best regards,

Sascha