# Help, dynamic limiting duration of stream/disconnect after X minutes(Schedule Thread)

**URL:** <https://community.wowza.com/t/help-dynamic-limiting-duration-of-stream-disconnect-after-x-minutes-schedule-thread/41370>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [April 26, 2014, 8:30pm UTC](https://community.wowza.com/t/help-dynamic-limiting-duration-of-stream-disconnect-after-x-minutes-schedule-thread/41370 "2014-04-26T20:30:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Florida\_Stream](https://avatars.discourse-cdn.com/v4/letter/f/6a8cbe/32.png) [@Florida\_Stream](https://community.wowza.com/u/Florida_Stream)\
**Post date:** [April 26, 2014, 8:30pm UTC](https://community.wowza.com/t/help-dynamic-limiting-duration-of-stream-disconnect-after-x-minutes-schedule-thread/41370/1 "2014-04-26T20:30:12Z")

</div>

Hello I would like to ask for any help with what I will describe , after days , hours and hours studying this function without success , I decided to try the last instance ask for help from someone who knows these functions .

I have this data in the database.

**Userid | Remaining Time**

**Username1 | 10**

where 10 are 10 minutes

I need to check every minute through a thread , even if the User has the minutes or not , if you still own, still running stream , it does not close the stream to the user .

For this to happen in a lighter way to the server , it would be good to pass the value “ **10** ” to a temporary variable , and thus be checking it .

```auto
run every minute 
example.: tempmin = 10
HERE function that does the checking , the regressive tempmin
if ( tempmin < 1 ) {
close user stream session
//rest of code, upgrade database
}
else { 
continue playing
}

```

The problem is I do not know even know how to do this in wowza , a simple example would help me a lot so I could continue from there .

I have not found a way to set a countdown in minutes/seconds etc to live/vod streaming .

I have failed in all attempts to set up a shedule for the thread .

Basically , I need an example , already envisioned dozens of tutorials , hundreds of posts , and unfortunately did not help me .

Thank you in advance .

---

<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:** [May 1, 2014, 2:50pm UTC](https://community.wowza.com/t/help-dynamic-limiting-duration-of-stream-disconnect-after-x-minutes-schedule-thread/41370/2 "2014-05-01T14:50:26Z")

</div>

You can use the [ModuleTimedDisconnect](https://www.wowza.com/docs/how-to-disconnect-connected-clients-after-a-specified-time-period-moduletimeddisconnect%28ModuleTimedDisconnect%29) for this.

Richard

---

<div class="post-metadata">

**Author:** ![Florida\_Stream](https://avatars.discourse-cdn.com/v4/letter/f/6a8cbe/32.png) [@Florida\_Stream](https://community.wowza.com/u/Florida_Stream)\
**Post date:** [May 3, 2014, 12:48am UTC](https://community.wowza.com/t/help-dynamic-limiting-duration-of-stream-disconnect-after-x-minutes-schedule-thread/41370/3 "2014-05-03T00:48:47Z")

</div>

> Hi!
> 
> The latest version of Wrench added support for [dynamic credit balance checking for players](http://wowzatoolbox.com/dynamic-balance). That means that you can have an initial balance for each connected player, like 5 minutes, and if they get score / pay for more minutes / whatever, their balance can go up. Wrench will periodically decrease their balance. If the balance goes down to 0, they are disconnected. This is more powerful than the above suggested ModuleTimedDisconnect. [Here is my tutorial about this](http://wowzatoolbox.com/dynamic-balance).

Thanks for the help, I’ll try it, however I need help with the source code for custom implementation, and simple code, I am beginner.

I’m making progress at a slow pace, anyway, thanks for the help.

> Is there any way to create global variables?
> 
> @Edit: I found here: [https://www.wowza.com/forums/showthread.php?25205-Server-Custom-Global-Variables](https://www.wowza.com/forums/showthread.php?25205-Server-Custom-Global-Variables)
> 
> Tks.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/system/32/447_2.png) [@system](https://community.wowza.com/u/system)\
**Post date:** [May 2, 2014, 4:06pm UTC](https://community.wowza.com/t/help-dynamic-limiting-duration-of-stream-disconnect-after-x-minutes-schedule-thread/41370/4 "2014-05-02T16:06:21Z")

</div>

Hi!

The latest version of Wrench added support for [dynamic credit balance checking for players](http://wowzatoolbox.com/dynamic-balance). That means that you can have an initial balance for each connected player, like 5 minutes, and if they get score / pay for more minutes / whatever, their balance can go up. Wrench will periodically decrease their balance. If the balance goes down to 0, they are disconnected. This is more powerful than the above suggested ModuleTimedDisconnect. [Here is my tutorial about this](http://wowzatoolbox.com/dynamic-balance).
