远程服务器返回错误:227 Entering Passive Mode (500 oops vs_utility_recv_peek: no data) [英] The remote server returned an error: 227 Entering Passive Mode (500 oops vs_utility_recv_peek: no data)

查看:179
本文介绍了远程服务器返回错误:227 Entering Passive Mode (500 oops vs_utility_recv_peek: no data)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将 Windows 服务连接到 FTP 站点时遇到问题.

I am having a problem connecting a Windows service to an FTP site.

我从另一个开发人员那里继承了一项 Windows 服务.该服务连接到第 3 方服务器,下载 csv 文件,然后对其进行处理.由于某种原因,该服务停止工作(一年多以前,在我获得项目之前).

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).

所以我回到了基础,创建了一个控制台应用程序,并仅在该应用程序中尝试了连接/文件下载功能.我尝试了许多不同的方法来连接到 FTP,但它们都向我的应用程序返回相同的错误:

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:

远程服务器返回错误:227 Entering Passive Mode ()

The remote server returned an error: 227 Entering Passive Mode ()

这是我尝试过的众多方法之一:

This is one of the many methods I've tried:

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(); 

但它落在这部分:

FtpWebResponse response = (FtpWebResponse)request.GetResponse();

我在几个论坛中看到将 UsePassive 属性设置为 False 可以修复这些错误,但发生在我身上的只是我得到了一个语法错误,如下所示:

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:

远程服务器返回错误:(500) 语法错误,命令无法识别.

The remote server returned an error: (500) Syntax error, command unrecognized.

该文件托管在我无法控制的第 3 方 FTP 服务器上.我可以将 URL 粘贴到浏览器中,系统会提示我输入用户名和密码,然后我就可以通过并下载文件.

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.

为了消除我们的防火墙作为问题的原因,我在内部网络和 WiFi(不在防火墙后面)上运行了该应用程序,这没有任何区别.我还在默认、主动和被动模式下通过 FileZilla 进行连接,并且每次都能正常工作.所以没有问题.

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.

然后我运行了 Wireshark.这是在被动模式下使用 Filezilla(即成功的)捕获线路的图像:

So then I ran Wireshark. Here is an image of the wire capture using Filezilla (i.e. a successful one), in Passive mode:

这是使用应用程序连接(和失败)时的捕获,被动设置为 true:

And here is the capture when connecting (and failing) using the app, with passive set to true:

所以正如您在上面的失败连接中看到的那样,我可以很好地登录服务器.然后无论出于何种原因发送了一个额外的请求,即TYPE I",它提示切换到二进制模式"的响应.在下面,我得到以下内容:

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:

500 oops:vsf_sysutil_recv_peek:无数据

500 oops: vsf_sysutil_recv_peek: no data

另外我也把Passive属性设置为false后又跑了一次,这就是我当时得到的:

In addition, I also ran it again after setting the Passive property to false, and this is what I got that time:

所以我的问题是双重的;

So my question is twofold;

1,如果我以某种方式解决了 UsePassive 问题并将该属性设置为 false,那会解决我的问题吗?

1, if I somehow get past the UsePassive issue and set that property to false, will that solve my problem?

2,忽略 UsePassive 属性,为什么我不能从应用程序下载文件,但可以从其他地方下载文件?

2, ignoring the UsePassive property, why can't I download the file from the app, but can from everywhere else?

推荐答案

问题现已解决.原来是卡巴斯基的内置防火墙阻止了连接.很烦人,当我尝试连接时它没有向我显示警告,但知道我的电脑是安全的.

The issue is now resolved. It turned out to be Kaspersky's built-in firewall that was blocking the connection. It's annoying that it didn't present me with a warning when I tried to connect, but reassuring to know my PC is safe.

线索在 227 返回的细节中:

The clue was in the detail of the 227 return:

10051 – 尝试对无法访问的网络进行套接字操作

10051 – A socket operation was attempted to an unreachable network

此外,对于通过 Google 等访问此内容的任何人,远程服务器被配置为仅允许被动连接,这就是我收到 500 语法错误的原因.研究下载文件时的 Wire 捕获发现,如果选择 Active 但失败,Filezilla 实际上会自动恢复到 Passive 模式.

Also, for anyone reaching this via Google etc, the remote server was configured to only allow Passive connections, which is why I was getting the 500 syntax error. Studying a Wire capture when downloading a file revealed that Filezilla actually reverts to Passive mode automatically if Active is selected but fails.

我原来帖子中的代码现在可以正常工作了.

The code in my original post works fine now.

这篇关于远程服务器返回错误:227 Entering Passive Mode (500 oops vs_utility_recv_peek: no data)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆