【问题标题】:Azure - Website - WebJob - Active FTP DownloadAzure - 网站 - WebJob - 主动 FTP 下载
【发布时间】: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)”

有人对我能做什么有任何建议吗?

编辑:据我所知,这不是虚拟机,我无法控制防火墙。这是一个标准的网站。 非常感谢!

【问题讨论】:

    标签: azure ftp


    【解决方案1】:

    我遇到了同样的问题,我可以通过增加每点的连接限制来解决。默认情况下它设置为 2 我增加到 10

    req.ServicePoint.ConnectionLimit = 10;

    如果你有超时问题,还要更改属性 timeout 和 readwritetimeout。

    以下是与我们类似的案例的链接。

    How can I programmatically remove the 2 connection limit in WebClient

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-19
      • 1970-01-01
      相关资源
      最近更新 更多