【发布时间】:2014-05-08 19:57:51
【问题描述】:
我正在使用 Windows Azure 网站和 Web 作业。
我有一个控制台应用程序,用于每晚下载一个 FTP 文件。他们最近从被动 FTP 切换到主动 FTP。我对此没有任何控制权。
附加的代码在我的计算机上适用于被动,也适用于主动。但是,当我将它添加到 Azure 上的网络作业时,它不起作用。
在此代码中,我能够获取内容长度,因此我正确登录并且拥有正确的 URL。
Dim request As FtpWebRequest = DirectCast(FtpWebRequest.Create(strTempFTPUrl), FtpWebRequest)
request.Method = WebRequestMethods.Ftp.GetFileSize
Dim nc As New NetworkCredential(FTPUserName, FTPPassword)
request.Credentials = nc
request.UseBinary = True
request.UsePassive = False
request.KeepAlive = True
request.Proxy = Nothing
' Get the result (size)
Dim resp As FtpWebResponse = DirectCast(request.GetResponse(), FtpWebResponse)
Dim contLen As Int64 = resp.ContentLength
' and now download the file
request = DirectCast(FtpWebRequest.Create(strTempFTPUrl), FtpWebRequest)
request.Method = WebRequestMethods.Ftp.DownloadFile
request.Credentials = nc
request.UseBinary = True
request.UsePassive = False
request.KeepAlive = True
request.Proxy = Nothing
resp = DirectCast(request.GetResponse(), FtpWebResponse)
我收到的错误是这样的:
底层连接已关闭:接收时发生意外错误。这发生在第二个“resp = DirectCast(request.GetResponse(), FtpWebResponse)”
有人对我能做什么有任何建议吗?
编辑:据我所知,这不是虚拟机,我无法控制防火墙。这是一个标准的网站。 非常感谢!
【问题讨论】: