How can I simulate blocking RTMP over port 80 on Windows?

Christian Nunciato picture Christian Nunciato · May 24, 2010 · Viewed 9.3k times · Source

I've got a simple Flash client connecting to a Flash Media Server, and I'd like to be able to simulate the client doing the following:

  • Attempting to connect to an RTMP stream on port 1935 and failing,
  • Falling back to RTMP on port 443 and failing,
  • Falling back to RTMP on port 80 and failing, and ultimately
  • Falling back to RTMPT (HTTP) over port 80 and succeeding.

This is supposed to be the default behavior of the Flash player, for example as described here:

In many cases, this is all you need to get past many firewalls without even using HTTP tunneling. This works because of a feature built into the NetConnection object. When you do not specify a port number in an RTMP address, Macromedia Flash will attempt to connect to port 1935. If it fails it will then try to connect to port 443; if that fails, it will try port 80. So no coding is required to access ports 1935, 443, or port 80 if you do not specify a port in the RTMP address.

And here:

When connecting to FMS you'll use a netConnection object on the client side, within the parameters of the connect method you can set what protocol you want to use: nc.connect("rtmp://whatever"). If you do that it should be noted that the flash player will cycle through different ports and protocols trying to connect up automatically. Of course you can set which protocol you want to use by changing the rtmp part. The Flash player will try connecting to rtmp over port 1935, then port 80, then it'll try rtmpt (covered below) over port 80.

I'm on a Windows 7 machine, and essentially I'm looking for tips as to how I can simulate an environment in which Flash fails to connect to an RTMP stream on any port and falls back to RTMPT. Windows Firewall seems to allow for setting a "protocol number" (in addition to the usual port number -- e.g., TCP is 6, UDP 17, etc.), but I can't seem to find a protocol number for RTMP.

If anyone has any suggestions as to how I can simulate this behavior simply, I'd hugely appreciate it. Many thanks in advance.

Answer

Ken picture Ken · Mar 7, 2011

I was able to make this work using Firefox on Windows 7 with a proxy server running on the local machine (localhost). I used Windows Firewall to block outbound connections to ports 1935, 443 and 80 for the specific destination IP address for process: "plugin-container.exe" . (Believe Firefox 3.6 and greater use "plugin-container.exe" for running the Flash plugin.) And then I set the Windows system proxy settings (via IE, Tools->Internet Options->Connections->LAN settings) to use my local http proxy server. Interesting that Flash apparently uses the Windows proxy settings, rather than Firefox's, even when running from within Firefox.