FMS blocked port detection – ActionScript 3

Written by Garry Lachman (Admin). Filed under ActionScript 3. Tagged , , , , , , , , , , , . Bookmark the Permalink. Post a Comment. Leave a Trackback URL.

FMS block port detection – ActionScript 3

The fms port (1935) closed on many office firewalls, the problem
is that flash had 30 sec timeout before tunnle it to port 80.
Becouse that i write little script that use socket object to test the
port and tunnle it to http when port 1935 is closed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package
{
import flash.events.Event;
import flash.net.Socket;
import flash.events.IOErrorEvent
import flash.events.SecurityErrorEvent

/**
* @author Garry Lachman
*
* Usage:
* FMSPortTester.TestPorts(onSuccess)
* function onSuccess(_fmsURL:String):void   {
* }
*/

public class FMSPortTester
{
public static const FMS_URL:String = "127.0.0.1";
public static const PREFIX_1935:String = "rtmp://";
public static const PREFIX_80:String = "rtmpt://";

public static const SOCKET_TIMEOUT:Number = 3;

public function FMSPortTester() {   trace("static only class"); }

public static function TestPorts(_resultURLCallBack:Function):void  {
// Create socket connection to fms to check the ports
var socketTest:Socket = new Socket();
socketTest.connect(FMS_URL, 1935);
socketTest.addEventListener(Event.CONNECT, onSocketConnected);
socketTest.addEventListener(IOErrorEvent.IO_ERROR, onSocketError);
socketTest.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onSocketError);
socketTest.timeout = (SOCKET_TIMEOUT * 1000);

// is connected, fms ports ok
function onSocketConnected(_e:Event):void   {
_resultURLCallBack(PREFIX_1935 + "" + FMS_URL);
}

// on error, fms ports closed
function onSocketError(_e:*):void   {
_resultURLCallBack(PREFIX_80 + "" + FMS_URL);
}
}
}
}
Share

2 Comments

  1. Kania
    Posted May 16, 2010 at 7:13 pm | Permalink

    How to run this script ?

  2. admin
    Posted May 16, 2010 at 9:43 pm | Permalink

    FMSPortTester.TestPorts(returnURL);
    function returnURL(_url:String):void {
    // _url = the fms url
    }

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*