<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ian Serlin &#187; Wowza Media Server</title>
	<atom:link href="http://ianserlin.com/index.php/category/wowza-media-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://ianserlin.com</link>
	<description>identifying pain points and creating chaos since 1984</description>
	<lastBuildDate>Fri, 08 Jan 2010 00:18:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Why IE doesn&#8217;t drop Flash NetConnections / NetStreams and how to fix it.</title>
		<link>http://ianserlin.com/index.php/2009/03/10/why-ie-doesnt-drop-flash-netconnections-netstreams-and-how-to-fix-it/</link>
		<comments>http://ianserlin.com/index.php/2009/03/10/why-ie-doesnt-drop-flash-netconnections-netstreams-and-how-to-fix-it/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 02:56:40 +0000</pubDate>
		<dc:creator>Ian Serlin</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Wowza Media Server]]></category>
		<category><![CDATA[problem solution]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[netconnection]]></category>
		<category><![CDATA[netstream]]></category>

		<guid isPermaLink="false">http://ianserlin.com/?p=7</guid>
		<description><![CDATA[Problem
The Adobe Flash Player ActiveX control for Internet Explorer 7 (I don&#8217;t know about IE6) will not disconnect NetConnections if the connection was made by a swf instance loaded in a tab and only that tab was closed. If IE itself is closed though the NetConnection will be dropped. This could lead to hung &#8220;ghost&#8221; [...]]]></description>
			<content:encoded><![CDATA[<h2>Problem</h2>
<p>The Adobe Flash Player ActiveX control for Internet Explorer 7 (I don&#8217;t know about IE6) will not disconnect NetConnections if the connection was made by a swf instance loaded in a tab and only that tab was closed. If IE itself is closed though the NetConnection will be dropped. This could lead to hung &#8220;ghost&#8221; connections where you won&#8217;t hear any audio, etc. but your <a title="Wowza Media Server Pro" href="http://wowzamedia.com">Wowza Media Server</a> (and maybe Flash Media Server, who knows?) will still think the client is connected.</p>
<h2>Explanation</h2>
<p>Laziness on the part of two large corporations.</p>
<h2>Solution</h2>
<p>Register a JS handler function for window.onbeforeunload that uses the Flash ExternalInterface to call a function in your swf that manually closes the NetConnection. The event &#8220;onbeforeunload&#8221; is recognized and executed by IE, Safari and Firefox before the onunload event is fired. It is apparently not handled by Opera AFAIK but that&#8217;s ok since IE is the only one that actually needs this fix.</p>
<p>In your ActionScript 3 code somewhere:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.external</span>.<span style="color: #004993;">ExternalInterface</span>;
&nbsp;
....
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> someFunction<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">ExternalInterface</span>.<span style="color: #004993;">available</span> <span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
&nbsp;
<span style="color: #004993;">ExternalInterface</span>.<span style="color: #004993;">addCallback</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;disconnect&quot;</span>, disconnect<span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> disconnect<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
&nbsp;
_my_net_connection1.<span style="color: #004993;">close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>In your Javascript code for the page that loads your swf:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
window.<span style="color: #660066;">onbeforeunload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// pure JS</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> swf <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mySwf'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
swf.<span style="color: #660066;">disconnect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// jQuery 1.2.6 version</span>
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mySwf&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">disconnect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The End</p>
]]></content:encoded>
			<wfw:commentRss>http://ianserlin.com/index.php/2009/03/10/why-ie-doesnt-drop-flash-netconnections-netstreams-and-how-to-fix-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

