# Live streaming stops automatically after 15 minutes

**URL:** <https://forum.kirupa.com/t/live-streaming-stops-automatically-after-15-minutes/261731>\
**Category:** Uncategorized\
**Created:** [May 30, 2008, 10:21am UTC](https://forum.kirupa.com/t/live-streaming-stops-automatically-after-15-minutes/261731 "2008-05-30T10:21:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![testmatrix](https://avatars.discourse-cdn.com/v4/letter/t/ecb155/32.png) [@testmatrix](https://forum.kirupa.com/u/testmatrix)\
**Post date:** [May 30, 2008, 10:21am UTC](https://forum.kirupa.com/t/live-streaming-stops-automatically-after-15-minutes/261731/1 "2008-05-30T10:21:51Z")

</div>

I am using flash media server 3 and flash media encoder 2.5. From media encoder I am sending data to media server and then in browser I am running flex application (version 3) to view the live stream. I am not saving it in flv file. After 15 mintues live streaming stops automatically. Flex3 application is just working as a client.

Portion of code:

nc.connect (“rtmp://localhost/myLiveApp/instance1/”);  
…  
vid.attachNetStream (ns);  
ns.play(“flv:mylivestream”);

code in main.asc file :

application.onAppStart = function()  
{  
// generate random payload used in bw detection  
this.payload = new Array();  
for (var i=0; i\<1200; i++){  
this.payload\* = Math.random(); //16K approx  
}  
}

application.onConnect = function(p\_client, p\_autoSenseBW)  
{  
//Add security here  
//p\_client.writeAccess = “”; // prevents creating shared object or live streams.  
this.acceptConnection(p\_client);

```
p_client.audioSampleAccess = "/";
p_client.videoSampleAccess = "/"; 

if (p_autoSenseBW)
	this.calculateClientBw(p_client);
else
	p_client.call("onBWDone");

```

}

Client.prototype.getStreamLength = function(p\_streamName) {  
return Stream.length(p\_streamName);  
}

Client.prototype.checkBandwidth = function() {  
application.calculateClientBw(this);  
}

application.calculateClientBw = function(p\_client)  
{  
var res = new Object();  
res.latency = 0;  
res.cumLatency = 1;  
res.bwTime = 0;  
res.count = 0;  
res.sent = 0;  
res.client = p\_client;  
var stats = p\_client.getStats();  
var now = (new Date()).getTime()/1;  
res.pakSent = new Array();  
res.pakRecv = new Array();  
res.beginningValues = {b\_down:stats.bytes\_out, b\_up:stats.bytes\_in, time:now};  
res.onResult = function(p\_val) {

```
	var now = (new Date()).getTime()/1;
	this.pakRecv[this.count] = now;
	trace("** onResult this.count = " + this.count + " : this.sent " + this.sent);
	//trace( "Packet interval = " + (this.pakRecv[this.count] - this.pakSent[this.count])*1 );
	this.count++;
	var timePassed = (now - this.beginningValues.time);

	if (this.count == 1) {
		this.latency = Math.min(timePassed, 800);
		this.latency = Math.max(this.latency, 10);
	}

	//trace("count = " + this.count + ", sent = " + this.sent + ", timePassed = " + timePassed);

	// If we have a hi-speed network with low latency send more to determine
	// better bandwidth numbers, send no more than 6 packets
	if ( this.count == 2 && (timePassed&lt;2000))
	{
		this.pakSent[res.sent++] = now;
		this.cumLatency++;
		this.client.call("onBWCheck", res, application.payload);
	}
	else if ( this.sent == this.count )
	{	
		// See if we need to normalize latency
		if ( this.latency &gt;= 100 )
		{ // make sure we detect sattelite and modem correctly
			if ( this.pakRecv[1] - this.pakRecv[0] &gt; 1000 )
			{
				this.latency = 100;
			}
		}

		// Got back responses for all the packets compute the bandwidth.
		var stats = this.client.getStats();
		var deltaDown = (stats.bytes_out - this.beginningValues.b_down)*8/1000;
		var deltaTime = ((now - this.beginningValues.time) - (this.latency * this.cumLatency) )/1000;
		if ( deltaTime &lt;= 0 )
			deltaTime = (now - this.beginningValues.time)/1000;
		
		var kbitDown = Math.round(deltaDown/deltaTime);

```

trace("onBWDone: kbitDown = " + kbitDown + ", deltaDown= " + deltaDown + ", deltaTime = " + deltaTime + ", latency = " + this.latency + "KBytes " + (stats.bytes\_out - this.beginningValues.b\_down)/1024) ;

```
		this.client.call("onBWDone", null, kbitDown, deltaDown, deltaTime, this.latency );
	}
}
res.pakSent[res.sent++] = now;
p_client.call("onBWCheck", res, "");
res.pakSent[res.sent++] = now;
p_client.call("onBWCheck", res, application.payload);

```

}

What is the problem? From media server console I can see 2 connection for 15 minutes and after that it drops to 1.  
I have tested it with medium and low bandwith.

Any help is appreciated.\*
