70
Client-Side ActionScript Language Reference
In general, use the RTMP protocol, which opens a persistent connection between Flash Player
and Flash Media Server. If, however, clients are connecting from behind a firewall or through
HTTP proxy servers that prohibit direct RTMP socket connections, use the RTMPT
protocol, which transmits RTMP data over an HTTP connection. The RTMPT protocol
explicitly requests an HTTP connection and enables a faster connection time for clients who
can’t connect through RTMP.
RTMPS connections use port 443 by default.
If Flash Player fails to connect to the server over an RTMP connection on the default port, it
will automatically try to establish a connection using a predetermined sequence of ports and
protocols. For example, if an application tries and fails to connect using
my_nc.connect("rtmp:/myserver/myapp")
, Flash Player will automatically try the
following sequence of connections, until successful:
my_nc.connect("rtmp://myserver:443/myapp");
my_nc.connect("rtmp://myserver:80/myapp");
my_nc.connect("rtmpt://myserver:80/myapp");
This connection sequence can enable connections to succeed that otherwise would not.
However, during this connection sequence users may wait several seconds for multiple
connection attempts to time out.
If you want to use this connection for publishing or playing audio or video in real time, or to
publish or play previously recorded audio or video streams, you must connect to the Flash
Media Server and then create a NetStream object within this NetConnection object. For more
information, see the
NetStream class
entry.
If you want to use this connection for synchronizing data among multiple clients or between
the client and a server, you must connect to the Flash Media Server and then create a remote
shared object within this NetConnection object. For more information, see the
SharedObject
class
entry.
When you call this method, the
NetConnection.onStatus
event handler is invoked with an
information object that specifies whether the connection succeeded or failed. For more
information, see
NetConnection.onStatus
. If the connection is successful,
NetConnection.isConnected
is set to
true
.
NO
TE
This automatic retry sequence will occur only if the initial connection specifies the RTMP
protocol and uses the default port—for example,
my_nc.connect("rtmp:/myserver/
myapp")
.