From: Reese Chappuis Date: 2011-09-20T05:49:16+09:00 Subject: Re: FTP ports --bcaec51b9cf3cf2f9e04ad5179e8 Content-Type: text/plain; charset=ISO-8859-1 Thank you! That worked- and sorry Sam- the link you gave me just showed me to the net/ftp page, and I didn't see anything about passive in there On Sun, Sep 18, 2011 at 9:56 PM, Gary Wright wrote: > > On Sep 18, 2011, at 9:18 PM, Reese Chappuis wrote: > > > The connect method suggestion didn't work. And I just noticed another > thing- > > the port number in the error keeps changing. In one test it was 11742, > and > > in the next it was 11728. > > ftp is an old protocol and has a somewhat unique architecture. > > The command connection is initiated by the client towards port 21. When an > actual > file transfer is needed, the *client* begins listening on a local port that > is > picked by the OS (sometimes called an ephemeral port). The client then > tells the > server which port number was allocated via the control connection (11742 > then > 11728 in your instance). > > At this point the *server* initiates a data connection to > the client towards the port number that was allocated by the client system. > This > is called 'active mode' in the protocol spec. This is where problems > usually > occur because many firewalls or administrative policies block that incoming > TCP connection from the server to the client. > > An alternative is to tell ftp to use 'passive mode'. In this mode, the > *server* > picks an ephemeral port, tells the client what it picked via the command > connection, and then the client establishes the data connection towards the > server. In this mode the two TCP connections are both outbound from the > client > and can often negotiate any firewalls as necessary. > > You may be experiencing problems with either of these modes based on the > firewall policies between the client and the server. > > You can set passive mode on as follows (based on quick look at net/ftp): > > ftp = Net::FTP.new(hostname) > ftp.passive = true # make sure you do this, defaults > to false > ftp.login uname, pass > ftp.puttextfile filename, rfilename > ftp.close > > > Gary Wright > -- Reese Chappuis --bcaec51b9cf3cf2f9e04ad5179e8--