Copy link to clipboard
Copied
Hi
I had created simple p2p rtmfp video conferencing application. Peers connect to server to get the id. Server side script is written for this purpose. This application was working earlier.
Now suddenly connection to server via netconnection is giving error. First it shows message NetConnection.Connect.Failed & later if tried to connect it gives NetConnection.Connect.Closed message. If I continue to connect using timer, after long time 3-4 minutes it gets connected & NetConnection.Connect.Success message appears.
Traced info.description, but could not find the reason for connection Fail & close. Can you please tell if I am missing on anything ?
Below is the code for connecting to AMS
videoServerUrl = "rtmfp://serveripaddress:1980/mtg/Room" + callId;
checkconnectionTimer.addEventListener(TimerEvent.TIMER, timerListener);
netConnection = new NetConnection();
connectToVideoServer();
private function connectToVideoServer(): void
{
trace("entered into connect to video server");
netConnection.addEventListener(NetStatusEvent.NET_STATUS, this.onNetConnectionStatus);
netConnection.connect(videoServerUrl,true,userName,roleId);
netConnection.client = this;
trace("connect to video server");
}
private function timerListener (e:TimerEvent):void {
if (!connectionStatus)
{
connectToVideoServer();
}
}
private function onNetConnectionStatus(event:NetStatusEvent):void {
trace("In netconnectionstatus " + event.info.code + event.info.description );
try
{
switch (event.info.code) {
case "NetConnection.Connect.Success":
//publish();
//player = new Player( netConnection, this);
connectionStatus = true;
trace("In maintest player publisher connection ");
if(checkconnectionTimer.running)
checkconnectionTimer.stop();
break;
case "NetConnection.Connect.Closed":
// TODO put reconnect logic
trace("In connection closed " );
connectionStatus = false;
if(!checkconnectionTimer.running)
checkconnectionTimer.start();
break;
case "NetConnection.Connect.Failed":
// TODO put reconnect logic
trace("In connection failed cond " );
connectionStatus = false;
if(!checkconnectionTimer.running)
checkconnectionTimer.start();
break;
}
}
catch (e:Error)
{
trace("test " + e.message);
}
}
below is the trace output:
In netconnectionstatus NetConnection.Connect.Failed undefined
In connection failed cond
entered into connect to video server
In netconnectionstatus NetConnection.Connect.Closed undefined
In connection closed
connect to video server
entered into connect to video server
In netconnectionstatus NetConnection.Connect.Closed undefined
In connection closed
connect to video server
entered into connect to video server
In netconnectionstatus NetConnection.Connect.Closed undefined
In connection closed
connect to video server
entered into connect to video server
In netconnectionstatus NetConnection.Connect.Closed undefined
In connection closed
connect to video server
In netconnectionstatus NetConnection.Connect.Success Connection succeeded.
In maintest player publisher connection
Flash player 11.8 is used for testing