# How to terminate a HTTP Session when it is stilll running?

**URL:** https://community.wowza.com/t/how-to-terminate-a-http-session-when-it-is-stilll-running/40943
**Category:** Wowza Developer Dojo
**Tags:** wowza-streaming-server-java-api
**Created:** [April 21, 2014, 11:50pm UTC](https://community.wowza.com/t/how-to-terminate-a-http-session-when-it-is-stilll-running/40943 "2014-04-21T23:50:31Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Manh\_Hung\_Nguyen](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Manh\_Hung\_Nguyen](https://community.wowza.com/u/Manh_Hung_Nguyen)
#### Post date: [April 21, 2014, 11:50pm UTC](https://community.wowza.com/t/how-to-terminate-a-http-session-when-it-is-stilll-running/40943/1 "2014-04-21T23:50:31Z")

</div>

Hi everyone,

I want to terminate a http session which is running.

How can I do that.

Thank you.

---

<div class="post-metadata">

### Author: ![sal\_jefferson](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@sal\_jefferson](https://community.wowza.com/u/sal_jefferson)
#### Post date: [April 22, 2014, 8:39am UTC](https://community.wowza.com/t/how-to-terminate-a-http-session-when-it-is-stilll-running/40943/2 "2014-04-22T08:39:04Z")

</div>

Hi there, take a look at this guide:

[How to control access to an HTTP stream (cupertinostreaming, smoothstreaming, sanjosestreaming, mpegdashstreaming)](https://www.wowza.com/docs/how-to-control-access-to-http-streams-cupertinostreaming-sanjosestreaming-smoothstreaming-mpegdashstreaming%28cupertinostreaming-smoothstreaming-sanjosestreaming-mpegdashstreaming%29)

Salvadore

---

<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: [April 23, 2014, 3:20pm UTC](https://community.wowza.com/t/how-to-terminate-a-http-session-when-it-is-stilll-running/40943/3 "2014-04-23T15:20:28Z")

</div>

Hungnguyen,

You can do something like this:

```auto
String userID="123";
   List<IHTTPStreamerSession> HTTPClients = ThisAppIns.getHTTPStreamerSessions();
   Iterator<IHTTPStreamerSession> HTTPClientIter = HTTPClients.iterator();
   IHTTPStreamerSession ThisHTTPClient;
          while ( HTTPClientIter.hasNext() )  
                {  
                       ThisHTTPClient = HTTPClientIter.next();
                       if (userID.equalsIgnoreCase(ThisHTTPClient.getQueryStr()))
                    		   {
						   ThisHTTPClient.rejectSession();
						   ThisHTTPClient.shutdown();
                    		   }  
                }

```

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: [April 28, 2014, 5:44pm UTC](https://community.wowza.com/t/how-to-terminate-a-http-session-when-it-is-stilll-running/40943/4 "2014-04-28T17:44:04Z")

</div>

Hungnguyen,

There is nothing built-in to support that. Assuming you are using the Load Balancer, that would be a likely place to manage connections. You might use SharedObjects or HashMap in a HTTPProvider, which would be the entry point for HTTP playback clients. You check check querystring \> accept (reject) \> check Load Balancer for least loaded server \> Return html with video tag and playback URL.

Richard

---

<div class="post-metadata">

### Author: ![Manh\_Hung\_Nguyen](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Manh\_Hung\_Nguyen](https://community.wowza.com/u/Manh_Hung_Nguyen)
#### Post date: [April 22, 2014, 5:10pm UTC](https://community.wowza.com/t/how-to-terminate-a-http-session-when-it-is-stilll-running/40943/5 "2014-04-22T17:10:20Z")

</div>

I want to close a http Session which is running.

In my case, I use userid is a parameter in the url. I want to close the first http session when the second http session is created. The first and second http session have the same userid.

For my instance, I request the first stream with [http://wowza-server:1935/live/Stream1/playlist.m3u8?us=123456](http://wowza-server:1935/live/Stream1/playlist.m3u8?us=123456)

And then, I also request the second stream with [http://wowza-server:1935/live/Stream1/playlist.m3u8?us=123456](http://wowza-server:1935/live/Stream1/playlist.m3u8?us=123456).

How to Wowza Server close the first http Session, when the second http Session is created.

Hungnguyen

---

<div class="post-metadata">

### Author: ![Manh\_Hung\_Nguyen](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Manh\_Hung\_Nguyen](https://community.wowza.com/u/Manh_Hung_Nguyen)
#### Post date: [April 24, 2014, 2:02am UTC](https://community.wowza.com/t/how-to-terminate-a-http-session-when-it-is-stilll-running/40943/6 "2014-04-24T02:02:09Z")

</div>

Hi Richard,

I follow your guide, but it also kills the current session.

I have fix like that

```auto
List<IHTTPStreamerSession> HTTPClients = appInstance
.getHTTPStreamerSessions();
Iterator<IHTTPStreamerSession> HTTPClientIter = HTTPClients.iterator();
IHTTPStreamerSession ThisHTTPClient;
getLogger().info("HTTPClients size: " + HTTPClients.size());
while (HTTPClientIter.hasNext()) {
[INDENT]ThisHTTPClient = HTTPClientIter.next();
if (arrParams[0].equalsIgnoreCase(ThisHTTPClient.getQueryStr()) 
[INDENT][/INDENT]&& !ThisHTTPClient.getSessionId().equals(httpSession.getSessionId())
) {
[INDENT]ThisHTTPClient.rejectSession();
ThisHTTPClient.shutdown();[/INDENT]
}[/INDENT]
} 

```

And it works properly.

Thank you very much.

Hungnguyen

---

<div class="post-metadata">

### Author: ![Manh\_Hung\_Nguyen](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Manh\_Hung\_Nguyen](https://community.wowza.com/u/Manh_Hung_Nguyen)
#### Post date: [April 25, 2014, 12:18am UTC](https://community.wowza.com/t/how-to-terminate-a-http-session-when-it-is-stilll-running/40943/7 "2014-04-25T00:18:19Z")

</div>

Hi Richard,

I have another issue, I have a media system with multi Edge servers. Such as what I discribe above, when the second http session is created, the first http session is closed. However, it 's just useful on the same edge server.

How about multi edge servers?

Hungnguyen
