Skip navigation
yuanfei_1984
Currently Being Moderated

flash.net.NetConnection limit

Oct 14, 2013 1:52 AM

Tags: #netconnection.connect

Hi,

 

For load testing, I'm trying to connect to FMS server with multiple connections in a single air application. However, it seemed the connection is limited by air and only the first couple of connection requests are sent. The program is listed below, and I found only 180 out of 200 connections are connected successful, the connection.connect of the rests are called, but no packet is sent (monitored through network  sniffer) and no NetStatusEvent is raised. I doubt there is a limit for the NetConnection number by which more connection requests are forbidden. I'm using the flex sdk 4.5 on a windows workstation, any ideas?

 

 

package

{

import flash.display.Sprite;

import flash.events.NetStatusEvent;

import flash.events.TimerEvent;

import flash.net.NetConnection;

import flash.utils.Timer;

 

public class TestNetConnection

{

  private var timer:Timer;

  private var cons:Array=new Array();

  private var index:Number=0;

  public function TestNetConnection()

  {

   for(var i:Number=0;i<200;i++){

    cons.push(new Connector(i));

   }

  }

 

  public function start():void{

   timer=new Timer(200,200);

   timer.start();

   timer.addEventListener(TimerEvent.TIMER,startEgm);

  

  }

 

  public function startSync():void{

   for(var i:Number=0;i<cons.length;i++){

    Connector(cons[i]).connect();

   }

  }

 

  private function startEgm(event:TimerEvent):void{

   Connector(cons[index]).connect();

   index++

  }

}

}

 

package
{
import flash.display.Sprite;
import flash.events.AsyncErrorEvent;
import flash.events.IOErrorEvent;
import flash.events.NetStatusEvent;
import flash.events.SecurityErrorEvent;
import flash.net.NetConnection;

public class Connector
{
  private var index:Number;
  private var rtmpClientConnection:NetConnection;
  public function Connector(i:Number)
  {
   index=i;
  
  }
 
  public function connect():void{
   trace(index+': '+'connecting');
   rtmpClientConnection=new NetConnection();
   rtmpClientConnection.client=this;
   //mRTMPClientConnection['isAlive']=Delegate.create(this,isAlive);
   //mRTMPClientConnection['mmrCommStatus']=Delegate.create(this,mmrComm Status);
   rtmpClientConnection.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler );
   rtmpClientConnection.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler );
   rtmpClientConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler );
   rtmpClientConnection.addEventListener(SecurityErrorEvent.SECURITY_ERR OR, securityErrorHandler );
  
   rtmpClientConnection.connect("rtmp://XXX.XXX.XXX.XXX/IGT.SB.MMR","CLI ENT",0,'test_'+index);

 

  }
 
  public function close():void{
   trace(index+': '+'closing');
   rtmpClientConnection.close();
  }
 
  protected function securityErrorHandler(event:SecurityErrorEvent):void
  {
   trace('security:'+event);
  
  }
 
  protected function ioErrorHandler(event:IOErrorEvent):void
  {
   // TODO Auto-generated method stub
   trace('ioErrorHandler:'+event);
  }
 
  protected function asyncErrorHandler(event:AsyncErrorEvent):void
  {
   trace('asyncErrorHandler:'+event);
  
  }
 
  protected function netStatusHandler(event:NetStatusEvent):void
  {
   trace(index+': '+event.info.code);
   TestConnection.instance.Update(index+': '+event.info.code);
  }
}
}

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points