title: Ruby Passive FTP problems (Windows NT Server - Net::FTPReplyError, Net::FTPProtoError)
body: <p>I'm having trouble using net/ftp to connect to a Windows NT ftp server.  </p>
  
  <p>It seems some other clients are having trouble connecting to this server, but FileZilla has no problem at all.</p>
  
  <p>Here is the debug output from ruby's connection attempt:</p>
  
  <pre><code>[151] pry(main):1&gt; ftp = Net::FTP.new(ftp_address)
  =&gt; #&lt;Net::FTP:0x0000010e236fe0
   @binary=true,
   @debug_mode=false,
   @last_response="220 Microsoft FTP Service\n",
   @last_response_code="220",
   @logged_in=false,
   @mon_count=0,
   @mon_mutex=#&lt;Mutex:0x0000010e236f90&gt;,
   @mon_owner=nil,
   @open_timeout=nil,
   @passive=false,
   @read_timeout=60,
   @resume=false,
   @sock=#&lt;Net::FTP::BufferedSocket io=#&lt;TCPSocket:0x0000010e236f18&gt;&gt;&gt;
  [152] pry(#&lt;Site&gt;):1&gt; ftp.debug_mode = true
  =&gt; true
  [153] pry(#&lt;Site&gt;):1&gt; ftp.passive = true      
  =&gt; true
  [154] pry(#&lt;Site&gt;):1&gt; ftp.login(ftp_user, ftp_password)      
  put: USER &lt;redacted&gt;
  get: 331 Password required for &lt;redacted&gt;.
  put: PASS ********
  get: 230 User logged in.
  put: TYPE I
  get: 200 Type set to I.
  =&gt; true
  [155] pry(#&lt;Site&gt;):1&gt; ftp.chdir("/")
  put: CWD /
  get: 250 CWD command successful.
  =&gt; nil
  [156] pry(main):1&gt; ftp.putbinaryfile("/Users/home/Desktop/testupload.csv")
  put: PASV
  get: 27 Entering Passive Mode (0,1,2,3,192,119)
  Net::FTPReplyError: 27 Entering Passive Mode (0,1,2,3,192,119)
  from /Users/home/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/ftp.rb:978:in `parse227'
  [157] pry(main):1&gt; ftp.putbinaryfile("/Users/home/Desktop/testupload.csv")
  put: PASV
  get: 
  Net::FTPProtoError: 
  from /Users/home/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/ftp.rb:329:in `getresp'
  </code></pre>
  
  <p>And here is the output from filezilla:</p>
  
  <pre><code>Status: Resolving address of &lt;redacted host&gt;
  Status: Connecting to &lt;redacted ip&gt;:21...
  Status: Connection established, waiting for welcome message...
  Response: 220 Microsoft FTP Service
  Command:  USER &lt;redacted&gt;
  Response: 331 Password required for &lt;redacted&gt;.
  Command:  PASS ********
  Response: 230 User logged in.
  Command:  OPTS UTF8 ON
  Response: 200 OPTS UTF8 command successful - UTF8 encoding now ON.
  Status: Connected
  Status: Retrieving directory listing...
  Command:  PWD
  Response: 257 "/" is current directory.
  Status: Directory listing successful
  Status: Resolving address of &lt;redacted host&gt;
  Status: Connecting to &lt;redacted ip&gt;:21...
  Status: Connection established, waiting for welcome message...
  Response: 220 Microsoft FTP Service
  Command:  USER &lt;redacted&gt;
  Response: 331 Password required for &lt;redacted&gt;.
  Command:  PASS ********
  Response: 230 User logged in.
  Command:  OPTS UTF8 ON
  Response: 200 OPTS UTF8 command successful - UTF8 encoding now ON.
  Status: Connected
  Status: Starting upload of /Users/home/Desktop/testupload.csv
  Command:  CWD /
  Response: 250 CWD command successful.
  Command:  TYPE I
  Response: 200 Type set to I.
  Command:  PASV
  Response: 27 Entering Passive Mode (0,1,2,3,192,121)
  Command:  STOR testupload.csv
  Response: 150 Opening BINARY mode data connection.
  Response: 226 Transfer complete.
  Status: File transfer successful, transferred 97 bytes in 1 second
  Status: Retrieving directory listing...
  Command:  PASV
  Response: 27 Entering Passive Mode (0,1,2,3,192,122)
  Command:  LIST
  Response: 150 Opening BINARY mode data connection.
  Response: 226 Transfer complete.
  Status: Directory listing successful
  </code></pre>
  
  <p>(note that in the above 27 Entering Passive Mode (0,1,2,3,192,122) lines, 0,1,2,3 was the IP address of the server we're connecting to).</p>
  
  <p>Any idea what might cause this?  I've been getting similar (to the ruby response) strange FTP responses when using CyberDuck as a client.</p>