The differences in connection types for Flash Media Server
I've recently got a question about the difference between the different methods of connecting to Flash Media Server (or Wowza or Red5 for that matter) and figured this is good material for a written article rather than a video tutorial. For the purpose of this article I may refer only to FMS but the same information can be applied to Wowza and Red5.
What are the different protocols?
For connecting up to a media server of your choice (see above) there are 5 different methods. I'll try to cover them in some detail here.
3. RTMPS and RTMPTS
How are they applied to the connection?
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.
The base of it all, RTMP, what is it?
We need to understand what RTMP is all about first I think. This is the base of the rest of them and is relevant information to understanding what the rest are all about. To use the material on Adobe's site here (which is also where you can get the specs for RTMP), The Real-Time Messaging Protocol (RTMP) was designed for high-performance transmission of audio, video, and data between Adobe Flash Platform technologies, including Adobe Flash Player and Adobe AIR. RTMP is now available as an open specification to create products and technology that enable delivery of video, audio, and data in the open AMF, SWF, FLV, and F4V formats compatible with Adobe Flash Player.
Essentially it allows the flash player to make a persistance connection to FMS to allow live connections to applications for all kinds of fun and interesting applications from multiplayer games to live streaming and audio for conferencing and much more. It's TCP based not UDP. RTMP is the default protocol used when connecting up to FMS from the flash player.
From there we have different off shoots of rtmp.
rtmpt is the tunneling protocol of real time messaging. Essentially it tries to trick the network into thinking it's HTTP. Which in turn may get you through some corporate and stricter networks. It's much slower of course and requires a bit more resources. The main downfall of it though is the lag and inconsistency of the connection. Mainly because you are trying to "trick" the network, sometimes you get figured out and cut off.
RTMPS and RTMPTS
rtmps is the "older" version of securing real time messaging. It's like HTTPS, you need a secure certificate to make it run on FMS. What it does is encrypt the packets with SSL for more secure transmission. This is pretty CPU intensive for the server (relatively) and can cause issues for the application in some cases. If you need more security in the network transmission then this is one option out there. As with rtmpt, it's got more lag than rtmp. RTMPTS is RTMPS over the tunneling protocol (see RTMPT). This is slower than even RTMPS and RTMPT as expected.
rtmpe is the next option for encrypted messaging with FMS and the Flash player. This is Adobe's own encryption process and is faster and easier to use than rtmpt. rtmpe uses HMACSHA256 and Diffie-Hellman key exchange for cryptographic primitives. Essentially it's an industry standard out there that is used to encrypt the data transmitted back and forth and works rather well at that. It's been well met by those that use it and accepted as a great option to the much slower rtmps.
On a related note, rtmfp is something to keep your eye on. It's UDP based for faster transmission and will be used to talk from Flash player to Flash player rather than from Flash player to server to Flash player. See more details about that in Adobe's PDF on RTMFP.
Summary of it all
So to sum things up a bit, essentially if you can you want to use RTMP only. It's the fastest of them all but of course provides no security. If you are looking for more security in the transmission of the information then use RTMPE or RTMPS. Need to break through a tight network then use tunneling RTMPT. Ports are important here too, 80 will usually get you in though 1935 is the default for RTMP. 443 works well too so you may want to give that a shot. These ports are the most likely to be open to the RTMP packets.
Posted by: Graeme Bull on Aug 13, 2009
Share This Article
STi Chat for Wowza Media Server with Flex | Foundation Edition v4
This is a new and improved basic video/audio/text chat application with the ability to invite other users to a private room. The Foundation Edition is meant to give developers the building blocks they need to learn, as well as an entry level solution for those needing a basic chat system. The source code is in AS3 and MXML with the Flex 4.5 SDK. We will be working on more features for the chat as we go and all are free.