远程服务器返回错误:227进入被动模式(500哎呀vs_utility_recv_peek:无数据) [英] The remote server returned an error: 227 Entering Passive Mode (500 oops vs_utility_recv_peek: no data)

查看:6976
本文介绍了远程服务器返回错误:227进入被动模式(500哎呀vs_utility_recv_peek:无数据)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有连接的Windows服务到FTP站点的问题。

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

我继承了Windows服务从其他开发商。该服务连接到第三方服务器,下载一个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进入被动模式()

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



但它跌倒在这一部分:

But it falls down on this part:

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.

文件托管第三方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.

要消除我们的防火墙作为问题的原因,我跑了两个内部网络和无线网络(这是不是在防火墙后面)上的应用程序,它使没有什么区别。我还通过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:

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

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哎呀:vsf_sysutil_recv_peek:没有数据

500 oops: vsf_sysutil_recv_peek: no data

另外,我也跑它的被动属性设置为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

另外,对于任何人通过谷歌等达到这一点,在远程服务器被配置为只允许被动连接,这就是为什么我得到了500语法错误。研究一个线捕获当下载一个文件透露,如果主动选择,但失败了Filezilla的实际恢复到被动模式下自动。

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进入被动模式(500哎呀vs_utility_recv_peek:无数据)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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