Ports, firewalls, and Adobe Flash Media Server
By default, the Adobe Flash Media Server uses port 1935 for the RTMP (Real-Time Messaging Protocol). This port was assigned to Adobe for the Flash Media Server by the IANA (Internet Assigned Numbers Authority).
If a firewall is being used, this port needs to be opened. Otherwise, the server needs to be configured to use a different port in the<HostPort> tag of Adaptor.xml. Below is what the default entry for the <HostPortList> tag looks like:
<HostPortList>
<!-- Specifies what IP address and port(s) to bind to. This is specified -->
<!-- as a string in the form"<ip>:<port>,<port>,...,<port>". -->
<!-- For example, "127.0.0.1:1935,80,443". This says to bind to the IP -->
<!-- address of 127.0.0.1 on ports 1935, 80, and 443. You can bind to -->
<!-- any IP by not specifying anything in front of the colon. -->
<!-- For example, ":1935,80,443". This says to bind to any IP on ports -->
<!-- 1935, 80, and 443. If no colon is found, the data is assumed to be -->
<!-- an IP address, and will bind to port 1935 as the default. -->
<!-- For example, "127.0.0.1". This says to bind to IP 127.0.0.1 on port -->
<!-- 1935. If a colon is found but no ports are specified after it, port -->
<!-- 1935 is used as the default port in which to bind. -->
<!-- For example, "127.0.0.1:". This says to bind to IP 127.0.0.1 on -->
<!-- port 1935. If you wish to bind to multiple IP addresses on this -->
<!-- adaptor, specify additional <HostPort> tags; 1 for each additional -->
<!-- IP that you wish to bind to. NOTE: Another adaptor may also try to -->
<!-- bind to the same IP-port combination resulting in a conflict. This -->
<!-- is considered a conflict since it is undesirable to have more than -->
<!-- one adaptor listening on the same IP-port pair. To resolve this -->
<!-- conflict, the first adaptor to do the bind - wins. A warning will -->
<!-- be logged indicating that the specified IP-port combo is in-use. -->
<HostPort>:1935</HostPort>
</HostPortList>
With"Stateful Inspection" firewalls, traffic is inspected and non-HTTP traffic may get rejected; potentially preventing communication over RTMP even if the proper port is open. Consult the documentation for the particular firewall to determine how to configure it to allow RTMP traffic. In addition, a connecting client behind a firewall might not allow outgoing TCP/IP connections on the default RTMP port (1935). In this case, you can try using a different known port. This list contains common ports and the protocols they are typically used for:
| 25 (SMTP) | |
80 (Default HTTP) |
|
| 110 (POP3) | |
| 554 (RTSP) | |
| 1626 | |
| 5500 (securid) | |
| 7070 (RealServer/QuickTime) | |
| 8000 | |
| 8080 (HTTP) |
In Client-Side ActionScript, if a port is specified in the NetConnection.connect() statement, Adobe Flash Player attempts to connect only on the specified port:
nc.connect("rtmp:/mydomain.com:1935/myAppName");
Alternatively, a port number can be omitted from the URI:
nc.connect("rtmp:/mydomain.com/myAppName");
In the above case, Adobe Flash Player first attempts to connect using port 1935. If a connection is not made, the Flash Player then attempts to connect using port 80, and then port 443. Since web servers generally use port 80 and 443, it is best to have the Flash Media Server and web server on different machines in production. This differentiation maximizes the chances of a successful connection. If the Flash Media Server and the web server must be on the same machine, configure them to listen on different ports to avoid a port conflict. There are also ways to use Client-Side Communications ActionScript to connect to a number of ports in succession until a connection is made. Below is some sample code that can be used to do this:
#include "netdebug.as"
stop();
function init() {
portList = [1935, 80, 443, 8080, 7070];
i = 0;
nc = new NetConnection();
nc.onStatus = function(info) {
if (info.code == "NetConnection.Connect.Failed") {
trace("failed on "+portList[i]);
i++;
connectInterval = setInterval(doConnect, 100);
} else if (info.code == "NetConnection.Connect.Success") {
//call other functions here
trace(nc.uri+": "+info.code);
}
};
doConnect();
}
function doConnect() {
clearInterval(connectInterval);
trace("i is: "+i+" and portList[i] is: "+portList[i]);
nc.connect("rtmp://yourDomain.com:"+portList[i]+"/yourAppName");
}
init();
To use this code, edit the nc.connect() statement and change "yourDomain.com" to whatever domain is being connected to. Also change "yourAppName" to whatever the name of the application is. Simply add port numbers to the portList array to connect on additional ports.
Note:In the above code,setInterval andclearInterval must be used so that the successive connection attempts are not made too quickly. If they are made too quickly the code will break. The interval used (100 milliseconds) can probably be as little as 1 millisecond but 100 is used to ensure ample time to make a successful connection.
This content requires Flash
To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.
Download the free Flash Player now!
