title: why do I get "200 Type set to I. (Net::FTPReplyError)"
body: <p><strong>Note:</strong> that I have both blocks of code (see below) in the same .rb file. The first time ftp.getbinaryfile() works then it throws the error.</p>
  <p><strong>Note:</strong> that <code>file</code> variable is a static path to the file used for debugging purposes only.</p>
  <p>I have this code in <code>ruby 2.0.0p481 (2014-05-08) [x64-mingw32]</code></p>
  <pre><code>file = &quot;/Filetrack/E-mail_Gateway/_Installer/GA/E-mail Gateway_10.0_Changes_PUBLIC.pdf&quot;
  
  list = ftp.list('*')
  list.each{|item| 
  
    counter=counter+1
    counter++
    ftp.getbinaryfile(file, where_to_save+File.basename(file)+counter.to_s, 1024)
    puts &quot;downloaded - .each used&quot;
  }
  </code></pre>
  <p>then in the same .rb file I got this code</p>
  <pre><code>ftp.list('*') { |item| 
    puts &quot;downloading using .list('*') {&quot;
    counter++
    ftp.getbinaryfile(file, where_to_save+File.basename(file)+counter.to_s, 1024)
  
    puts &quot;downloaded #{file}&quot;
  }
  </code></pre>
  <p>and that code throws me this error</p>
  <pre><code>Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:974:in `parse227': 200 Type set to I. (Net::FTPReplyError)
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:394:in `makepasv'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:406:in `transfercmd'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:487:in `block (2 levels) in retrbinary'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:199:in `with_binary'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:485:in `block in retrbinary'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:484:in `retrbinary'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:617:in `getbinaryfile'
  </code></pre>
  <p>ftp session is created by</p>
  <pre><code>ftp = Net::FTP.new('ftp.***.***.net')
  ftp.passive = false
  ftp.debug_mode = true
  ftp.login(ftp_username, ftp_password)
  </code></pre>
  <p>could someone explain why the second version works?</p>
  <h1>UPDATE</h1>
  <p>Added ftp debugging log:</p>
  <pre><code>put: USER r.***
  get: 331 Password required for r.***.
  put: PASS ************
  get: 230-Welcome to FTP
  get: 230 User r.****logged in.
  put: TYPE I
  get: 200 Type set to I.
  put: CWD /Filetrack/E-mail_Gateway/_Installer/GA/010_000_003_000/
  get: 250 CWD command successful.
  put: TYPE A
  get: 200 Type set to A.
  put: PASV
  get: 227 Entering Passive Mode (194,212,10,23,195,92).
  put: LIST *
  get: 125 Data connection already open; Transfer starting.
  get: 226 Transfer complete.
  put: TYPE I
  get: 200 Type set to I.
  put: PASV
  get: 227 Entering Passive Mode (194,212,10,23,195,93).
  put: RETR /Filetrack/E-mail_Gateway/_Installer/GA/010_000_003_000/E-mail Gateway_10.0_Changes_PUBLIC.pdf
  get: 125 Data connection already open; Transfer starting.
  get: 226 Transfer complete.
  downloaded - .each used
  put: TYPE A
  get: 200 Type set to A.
  put: PASV
  get: 227 Entering Passive Mode (***,***,10,23,195,97).
  put: LIST *
  get: 125 Data connection already open; Transfer starting.
  downloading using .list('*') {
  put: TYPE I
  get: 226 Transfer complete.
  put: PASV
  get: 200 Type set to I.
  put: TYPE A
  get: 227 Entering Passive Mode (***,***,10,23,195,98).
  put: TYPE I
  get: 200 Type set to A.
  d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:974:in `parse227': 200 Type set to I. (Net::FTPReplyError)
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:394:in `makepasv'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:406:in `transfercmd'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:487:in `block (2 levels) in retrbinary'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:199:in `with_binary'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:485:in `block in retrbinary'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:484:in `retrbinary'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:617:in `getbinaryfile'
          from download2 - debugging.rb:41:in `block in &lt;main&gt;'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:518:in `block (3 levels) in retrlines'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:515:in `loop'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:515:in `block (2 levels) in retrlines'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:199:in `with_binary'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:512:in `block in retrlines'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:511:in `retrlines'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:760:in `list'
          from download2 - debugging.rb:38:in `&lt;main&gt;'
  </code></pre>
  <p><strong>UPDATE2</strong></p>
  <p>log if <code>ftp.passive = false</code> is used</p>
  <pre><code>downloading using .list('*') {
  put: TYPE I
  get: 226 Transfer complete.
  put: PORT ***,***,20,102,235,136
  get: 200 Type set to I.
  put: RETR /Filetrack/E-mail_Gateway/_Installer/GA/010_000_003_000/Email Gateway_10.0_Changes_PUBLIC.pdf
  get: 200 PORT command successful.
  put: TYPE A
  put: TYPE I
  d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/protocol.rb:211:in `write': An existing connection was forcibly closed by the remote host. (Errno::ECONNRESET)
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/protocol.rb:211:in `write0'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/protocol.rb:185:in `block in write'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/protocol.rb:202:in `writing'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/protocol.rb:184:in `write'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:283:in `putline'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:360:in `block in voidcmd'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:359:in `voidcmd'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:183:in `send_type_command'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:172:in `binary='
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:201:in `ensure in with_binary'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:201:in `with_binary'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:512:in `block in retrlines'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:511:in `retrlines'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:760:in `list'
          from download2 - debugging.rb:39:in `&lt;main&gt;'
  </code></pre>
  <p><strong>UPDATE3</strong></p>
  <p>I tried to run the same code in ftp active mode few times and actually all files are downloaded but the script finishes with an error.</p>
  <pre><code>downloading using .list('*') {
  put: TYPE I
  get: 200 Type set to I.
  put: PORT **,**,20,102,197,73
  get: 200 PORT command successful.
  put: RETR /Filetrack/E-mail_Gateway/_Installer/GA/010_000_003_000/E-mail Gateway_10.0_Changes_PUBLIC.pdf
  get: 150 Opening BINARY mode data connection for /Filetrack/E-mail_Gateway/_Installer/GA/010_000_003_000/E-mail Gateway_10.0_Changes_PUBLIC.pdf(
  60911 bytes).
  get: 226 Transfer complete.
  put: TYPE A
  get: 200 Type set to A.
  downloaded /Filetrack/E-mail_Gateway/_Installer/GA/010_000_003_000/E-mail Gateway_10.0_Changes_PUBLIC.pdf
  put: TYPE I
  get: 200 Type set to I.
  d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/protocol.rb:158:in `rescue in rbuf_fill': Net::ReadTimeout (Net::ReadTimeout)
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/protocol.rb:152:in `rbuf_fill'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/protocol.rb:134:in `readuntil'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:1108:in `readline'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:289:in `getline'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:300:in `getmultiline'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:318:in `getresp'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:338:in `voidresp'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:526:in `block (2 levels) in retrlines'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:199:in `with_binary'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:512:in `block in retrlines'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:511:in `retrlines'
          from d:/prog/Ruby200-x64/lib/ruby/2.0.0/net/ftp.rb:760:in `list'
          from download2 - debugging.rb:39:in `&lt;main&gt;'
  </code></pre>