# Unexpected disconnect event log4j

**URL:** https://community.wowza.com/t/unexpected-disconnect-event-log4j/41953
**Category:** Wowza Streaming Engine
**Created:** [March 13, 2014, 1:09am UTC](https://community.wowza.com/t/unexpected-disconnect-event-log4j/41953 "2014-03-13T01:09:01Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Vijay](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@Vijay](https://community.wowza.com/u/Vijay)
#### Post date: [March 13, 2014, 1:09am UTC](https://community.wowza.com/t/unexpected-disconnect-event-log4j/41953/1 "2014-03-13T01:09:01Z")

</div>

Hello,

I have the log4j system linked to a database, as you may know log4j records all events.

I am using wowza 3.6 VOD

When a user starts a video i get a record in the database with the connect and play event.

If a user stops or pauses the video i will get a stop/disconnect event.

The problem is when a user plays a video of a extended period of time (5min sometimes) i get a disconnect event even when the user is still playing the video.

I expect that i get the disconnect event when the user pauses or stops the video.

Does anyone have a solution to this?

Could it be that the user buffers the video so much that wowza thinks the user timeout-ed and sends a disconnect?

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [March 13, 2014, 12:44pm UTC](https://community.wowza.com/t/unexpected-disconnect-event-log4j/41953/2 "2014-03-13T12:44:56Z")

</div>

Sounds like RTMP playback. If a user is watching a video, the RTMP session has not disconnected yet. I would try some isolated tests. I suggest you take the database logging part out of it. Instead run Wowza in stand-alone (/bin/startup.bat) if you want to see logging in real-time.

Richard

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [March 13, 2014, 1:46pm UTC](https://community.wowza.com/t/unexpected-disconnect-event-log4j/41953/3 "2014-03-13T13:46:40Z")

</div>

I think I understand what you are seeing: with HLS streams to iOS devices there can be multiple sessions server-side for what is one playback session from the user’s point of view. If you need to tie them together for accounting purposes you can [use this technique](https://www.wowza.com/docs/how-to-track-streaming-by-users)

Richard

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [March 13, 2014, 3:10pm UTC](https://community.wowza.com/t/unexpected-disconnect-event-log4j/41953/4 "2014-03-13T15:10:40Z")

</div>

Accounting for HLS and other HTTP stream types is not as fine as RTMP. A system like yours will have to work with what is available. The player is in control when it comes to creating these sessions, not Wowza. You might be able to [use onHTTPSessionCreate and onHTTPSessionDestroy](https://www.wowza.com/docs/how-to-control-access-to-http-streams-cupertinostreaming-sanjosestreaming-smoothstreaming-mpegdashstreaming%28cupertinostreaming-smoothstreaming-sanjosestreaming-mpegdashstreaming%29) in some way to further manage sessions.

Richard

---

<div class="post-metadata">

### Author: ![Vijay](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@Vijay](https://community.wowza.com/u/Vijay)
#### Post date: [March 13, 2014, 5:26am UTC](https://community.wowza.com/t/unexpected-disconnect-event-log4j/41953/5 "2014-03-13T05:26:23Z")

</div>

> Sounds like RTMP playback. If a user is watching a video, the RTMP session has not disconnected yet. I would try some isolated tests. I suggest you take the database logging part out of it. Instead run Wowza in stand-alone (/bin/startup.bat) if you want to see logging in real-time.
> 
> Richard

Hello rrlanham,

We are using the m3u8 playlist.

We use the database (external) to limit the maximum amount of watchable videos at the same time for a single user in our application.

(a user is allowed to watch 2 videos at the same time, not limiting it to IP/device)

Our application is running on a other server then Wowza.

If you have a butter suggestion then checking the logs for user access i am happy to hear it.

---

<div class="post-metadata">

### Author: ![Vijay](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@Vijay](https://community.wowza.com/u/Vijay)
#### Post date: [March 13, 2014, 5:56am UTC](https://community.wowza.com/t/unexpected-disconnect-event-log4j/41953/6 "2014-03-13T05:56:54Z")

</div>

> I think I understand what you are seeing: with HLS streams to iOS devices there can be multiple sessions server-side for what is one playback session from the user’s point of view. If you need to tie them together for accounting purposes you can [use this technique](https://www.wowza.com/docs/how-to-track-streaming-by-users)
> 
> Richard

That is the tricked i used yes.

I made a few modifications for my needs:

```auto
log4j.appender.SQ.layout.Fields=x-sname-query
log4j.appender.SQ.layout.EventExclude=comment,vhost-stop,vhost-start,server-start,server-stop
log4j.appender.SQ.sql=INSERT IGNORE INTO accesslog (SELECT NULL AS id, '%X{date} %X{time}}' AS DATETIME, '%X{x-event}' AS EVENT, SUBSTRING_INDEX(SUBSTRING_INDEX('%X{x-sname-query}', '&', 2),'&',1) AS userid, SUBSTRING_INDEX(SUBSTRING_INDEX('%X{x-sname-query}%', '&', -2),'&',1) AS sessionid, SUBSTRING_INDEX(SUBSTRING_INDEX('%X{x-sname-query}%', '&', -1),'&',2) AS videoid, '%X{c-ip}' AS ip FROM ( SELECT NULL AS dummy_column) AS dummy_table WHERE '%X{x-event}' = 'connect' OR '%X{x-event}' = 'disconnect' LIMIT 1 ) ON DUPLICATE KEY UPDATE EVENT = '%X{x-event}'

```

I send the userId, sessionId and videoId to Wowza, with that i filter out all the needed data.

Since wowza has a delay of 30seconds between connect and disconnect i group the users with the session\_id so they can freely watch videos in the same browser without getting a notification that they hitted there limit.

I think that is why i am getting a early disconnect, one of the sessions of a IOS device disconnects and wowza updates that.

What happens when i just turn of the HLS?

**Edit:**

When i turn off HLS, the iPad stops playing the video ☹
