Ensuring high connection success rate
Why a connection attempt to a working media server might fail:
Red5, FMIS and Wowza by default only accept rtmp connections over port 1935. This will work fine for most home Internet connections however when your user is behind a corporate firewall/network he might hit 2 major restrictions:
- NO traffic/connections to non standard ports like 1935 (default port for rtmp). Traffic is only allowed to standard ports like 80 (http) and 443 (https) . The solution for this is to configure the media server to accept rtmp connections over ports 443 and 80 .
- NO non-http traffic allowed (or a proxy server is used). The solution for this is to configure the media server to accept rtmpt connections. Rtmpt is rtmp wrapped as http and its slower. It also adds some overhead/consumes more bandwidth because each rtmp packet needs to be wrapped as http. According to a 2004 Adobe article, only 4% of Internet users are behind such a network.
The automatic connection sequence in Flash Player:
By default, when a Flash Player app (AVChat 3 for example) tries to connect to a media server (Red5, FMIS or Wowza), it automatically tries to establish a connection by using the following sequence of ports and protocols:
- rtmp://myserver:1935/avchat30/_definst_
- rtmp://myserver:443/avchat30/_definst_
- rtmp://myserver:80/avchat30/_definst_
- rtmpt://myserver:80/avchat30/_definst_
This connection sequence can enable connections to succeed that otherwise would not. This automatic retry sequence occurs only if the initial connection specifies the RTMP protocol and does not specify a port – for example rtmp://myserver/avchat30/_definst_ . During this connection sequence, users may wait several seconds for multiple connection attempts to time out.
However for the above connection sequence to actually produce more sucessfull connection attempts, the media server must also be properly configured to listen for rtmp connections over ports 1935, 443 and 80 and for rtmpt connections over port 80.
Configuring your media server for best connection success rate:
[Before making the below changes make sure there is no other program listening on port 80 or 443 on your media server. These ports are surely already used by Apache. Use the netstat -ant command on linux to see which ports are already used. FMIS, Red5 and Wowza use port 1935 by default for a reason]
If you’re using FMIS:
- solution for restriction 1: configure it to listen for rtmp connections over ports 1935, 443 and 80. You need to edit conf/fms.ini, set ADAPTOR.HOSTPORT = :1935,443,80 and restart FMIS. Make sure you don’t have other apps (like the Apache web server) started and listening on 80 or 443.
- solution for restriction 2: same as above, FMIS can listen for both rtmp and rtmpt connections over the same ports at the same time
Most FMIS hosting services (like influxis.com) are already configured like this out of the box.
If you’re using Wowza:
- solution for restriction 1: make it listen for rtmp connections over ports 1935, 443 and 80. You need to edit conf/VHost.xml , set <Port>1935,443,80</Port> and restart Wowza. Make sure you don’t have other apps (like the Apache web server) started and listening on 80 or 443.
- solution for restriction 2: same as above, Wowza can listen for both rtmp and rtmpt connections over the same ports at the same time
If you’re using Red5:
- solution for restriction 1: bind rtmp connections to port 443 instead of 1935 (Red5 0.9 can not listen for rtmp connections over several simultaneous ports like Wowza and FMIS can). You need to edit conf/red5.properties, set rtmp.port=443 and restart Red5. Make sure you don’t have other apps (like the Apache web server) started and listening on 443 . You can also use port 80 but we will use that for listening for rtmpt connections as explained below.
- solution for restriction 2: bind rtmpt connections to port 80. You need to edit conf/red5.properties, set rtmpt.port=80 and restart Red5. Make sure you don’t have other apps (like the Apache web server) started and listening on 80.
How can you check your connection
Here you will find 2 port testers which will attempt to establish rtmp and rtmpt connections (using all ports) to a properly configured media server. Red5 ships with a similar tool and you can download another one from here.
More info
There is a great article (from 2005 I think) on the Adobe website that goes more in depth about these issues. I recommend you read it if you want to understand a little bit more about how the Internet works and why these steps are necessary and why such configurations are not the default: http://www.adobe.com/devnet/flashcom/articles/firewalls_proxy.html .
One thought on “Ensuring high connection success rate”
This is a great troubleshooting step thanks for sharing.