Having problems connecting RTMFP? Use this application to test NetConnection, NetStream, NetGroup connection and publishing status. For success connection, opened UDP ports in range 1024..65535 required. Run two instances to test NetGroup neighboring.
The code behind testing application:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="100%" height="100%" applicationComplete="init()">
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import flash.net.navigateToURL;
import org.osmf.net.NetConnectionCodes;
import org.osmf.net.NetStreamCodes;
private static const HANDSHAKE_URL:String = "rtmfp://stratus.rtmfp.net";
private static const DEVELOPER_KEY:String = "PUT***YOUR***OWN";
private var netConnection:NetConnection = new NetConnection();
private var netStream:NetStream;
private var netStream2:NetStream;
private var netGroup:NetGroup;
private var d0:Date
private function init():void
{
d0 = new Date();
netConnection.connect(HANDSHAKE_URL + "/" + DEVELOPER_KEY);
netConnection.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
}
private function netConnectionConnected():void
{
var groupSpecifier:GroupSpecifier = new GroupSpecifier("somegruop");
groupSpecifier.serverChannelEnabled = true;
groupSpecifier.multicastEnabled = true;
groupSpecifier.ipMulticastMemberUpdatesEnabled = true;
groupSpecifier.postingEnabled = true;
var groupspec:String = groupSpecifier.groupspecWithAuthorizations();
netStream = new NetStream(netConnection, groupspec);
netStream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
netStream2 = new NetStream(netConnection, groupspec);
netStream2.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
netGroup = new NetGroup(netConnection, groupspec);
netGroup.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
}
private function onNetStatus(event:NetStatusEvent):void
{
var code:String = event.info.code;
var time:Number = Math.round((new Date().time - d0.time)/10) / 100;
log.appendText(code + " (" + time + " sec)\n");
switch(code)
{
case NetConnectionCodes.CONNECT_SUCCESS:
netConnectionCheckBox.selected = true;
netConnectionConnected();
break;
case "NetStream.Connect.Success":
if(event.info.stream == netStream)
{
netStreamCheckBox.selected = true;
netStream.publish("test");
}
else if(event.info.stream == netStream2)
{
netStream2.play("test");
}
break;
case "NetGroup.Connect.Success":
netGroupCheckBox.selected = true;
break;
case NetStreamCodes.NETSTREAM_PUBLISH_START:
netStreamPublishCheckBox.selected = true;
break;
case NetStreamCodes.NETSTREAM_PLAY_START:
netStreamPlayCheckBox.selected = true;
break;
case "NetGroup.Neighbor.Connect":
netGroupNeighborCheckBox.selected = true;
break;
}
}
private function onReadMore():void
{
var url:String = "http://blog.yoz.sk/2010/06/quick-tip-ports-required-for-rtmfp/";
navigateToURL(new URLRequest(url), "_blank");
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:VGroup>
<s:HGroup verticalAlign="middle">
<s:CheckBox id="netConnectionCheckBox" enabled="false"/>
<s:Label text="NetConnection" />
</s:HGroup>
<s:HGroup verticalAlign="middle">
<s:CheckBox id="netStreamCheckBox" enabled="false"/>
<s:Label text="NetStream" />
</s:HGroup>
<s:HGroup verticalAlign="middle" paddingLeft="10">
<s:CheckBox id="netStreamPublishCheckBox" enabled="false"/>
<s:Label text="NetStream.Publish" />
</s:HGroup>
<s:HGroup verticalAlign="middle" paddingLeft="10">
<s:CheckBox id="netStreamPlayCheckBox" enabled="false"/>
<s:Label text="NetStream.Play" />
</s:HGroup>
<s:HGroup verticalAlign="middle">
<s:CheckBox id="netGroupCheckBox" enabled="false"/>
<s:Label text="NetGroup" />
</s:HGroup>
<s:HGroup verticalAlign="middle" paddingLeft="10">
<s:CheckBox id="netGroupNeighborCheckBox" enabled="false"/>
<s:Label text="NetGroup.Neighbor" />
</s:HGroup>
</s:VGroup>
<s:VGroup width="100%" height="100%">
<s:TextArea id="log" width="100%" height="100%" text="For success connection, opened UDP ports in range 1024..65535 required. Run two instances to test NetGroup neighboring. " />
<s:Button label="Read more about RTMFP requirements" click="onReadMore()"/>
</s:VGroup>
</s:Application>
Where to go from here:





