2017-08-10 9 views
1

FTPClientを使用してvb.netのセキュリティ保護されたftpサーバーに接続しようとしています。私は接続することができてアップロード/ダウンロードファイルを介してデータを。しかし、.netコードから、私はタイムアウトの問題を抱えています。私は間違いを犯しましたか、または私の次のコードに何か不足していますか?FTPClient - ソケットストリームからデータを読み取ろうとしたときにタイムアウトしました

Public Function ftpDownload(ByVal strFileName As String) As FileStream 
     Try 
      Dim client As New FtpClient("ftp://xxx.xxx.xxx.xxx") 
      client.Port = 990 
      client.Credentials = New NetworkCredential("myusername", "mypassword") 
      client.EncryptionMode = FtpEncryptionMode.Explicit 
      client.DataConnectionEncryption = True 
      client.ReadTimeout = 20000 
      client.DataConnectionType = FtpDataConnectionType.AutoPassive 
      'System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; 

      client.Connect() 

      Dim arr As New MemoryStream() 
      client.Download(arr, strFileName) 
      Using responseStream As IO.Stream = arr 
       Using fs As New IO.FileStream("c:\temp\temp.123", FileMode.Create) 
        Dim buffer(2047) As Byte 
        Dim read As Integer = 0 
        Do 
         read = responseStream.Read(buffer, 0, buffer.Length) 
         fs.Write(buffer, 0, read) 
        Loop Until read = 0 
        responseStream.Close() 
        'fs.Flush() 
        'fs.Close() 
        Return fs 
       End Using 
       responseStream.Close() 
      End Using 
     Catch ex As Exception 
      MsgBox(ex) 
      Return Nothing 
     End Try 

client.Connect()から例外がスローされています。以下のクイックウォッチウィンドウに見られるような例外のスクリーンショットです:

enter image description here

答えて

0

エラーメッセージがあなたのタイムアウトが低すぎるようにそれは私には見えるのです。ばかげたタイムアウトを設定し、トラフィックがまったくないかどうかを確認してください。最悪のシナリオでは、wiresharkを使用してFileZillaのリクエストと比較してください。 VBは手動のパケット操作では最適ではありませんが、要求パケットを比較することによって明らかになる構成に何か問題がある可能性があります。

関連する問題