title: The remote server returned an error: 227 Entering Passive Mode (500 oops vs_utility_recv_peek: no data)
body: <p>I am having a problem connecting a Windows service to an FTP site.</p>
  
  <p>I inherited a Windows service from another developer. The service connects to a 3rd party server, downloads a csv file and then processes it. For some reason, the service stopped working (well over a year ago, before I was given the project).</p>
  
  <p>So I went back to basics, created a console app and tried the connection/ file download function only in that app. I have tried many different methods to connect to the FTP, but all of them return the same error to my application:</p>
  
  <blockquote>
    <p>The remote server returned an error: 227 Entering Passive Mode ()</p>
  </blockquote>
  
  <p>This is one of the many methods I've tried:</p>
  
  <pre><code>FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://ftpaddress/filename.csv");
          request.Method = WebRequestMethods.Ftp.DownloadFile;
  
          request.Credentials = new NetworkCredential("username", "password");
  
          request.UsePassive = true;
  
          FtpWebResponse response = (FtpWebResponse)request.GetResponse();
  
          Stream responseStream = response.GetResponseStream();
          StreamReader reader = new StreamReader(responseStream);
          Console.WriteLine(reader.ReadToEnd());
  
          Console.WriteLine("Download Complete, status {0}", response.StatusDescription);
  
          reader.Close();
          response.Close(); 
  </code></pre>
  
  <p>But it falls down on this part:</p>
  
  <pre><code>FtpWebResponse response = (FtpWebResponse)request.GetResponse();
  </code></pre>
  
  <p>I read in several forums that setting the UsePassive property to False fixes these errors, but all that happened to me was that I got a syntax error instead, as below:</p>
  
  <blockquote>
    <p>The remote server returned an error: (500) Syntax error, command unrecognized.</p>
  </blockquote>
  
  <p>The file is hosted on a 3rd party FTP server I have no control over. I can paste the URL into a browser, and I am prompted for a username and password, which then allows me through and I can download the file.</p>
  
  <p>To eliminate our firewall as the cause of the problem, I ran the app on both the internal network and the WiFi (which isn't behind the firewall), and it makes no difference. I also connected through FileZilla in Default, Active and Passive modes, and it worked every time. So no problem there.</p>
  
  <p>So then I ran Wireshark. Here is an image of the wire capture using Filezilla (i.e. a successful one), in Passive mode:</p>
  
  <p><img src="https://i.stack.imgur.com/SS91B.png" alt="enter image description here"></p>
  
  <p>And here is the capture when connecting (and failing) using the app, with passive set to true:</p>
  
  <p><img src="https://i.stack.imgur.com/fhXic.png" alt="enter image description here"></p>
  
  <p>So as you can see in the failed connection above, I can log in to the server just fine. Then for whatever reason an extra request is sent, namely "TYPE I", which prompts the response of "Switching to binary mode." The  below that, I get the following:</p>
  
  <blockquote>
    <p>500 oops: vsf_sysutil_recv_peek: no data</p>
  </blockquote>
  
  <p>In addition, I also ran it again after setting the Passive property to false, and this is what I got that time:</p>
  
  <p><img src="https://i.stack.imgur.com/Z5F9e.png" alt="enter image description here"> </p>
  
  <p>So my question is twofold; </p>
  
  <p>1, if I somehow get past the UsePassive issue and set that property to false, will that solve my problem?</p>
  
  <p>2, ignoring the UsePassive property, why can't I download the file from the app, but can from everywhere else?</p>