0

I'm using a WebClient object and the method DownloadString to get some information from a site. The issue I am having is the server this program runs on only keeps port 80 open for a short while after the iniital connection is made. This means, if the site takes a short amount of time to get the data and send it back it works correctly. If however it takes a few minutes to get the data and send it back it will fail.

Is it possible to keep the connection open?

Or alternatively, is is possible to use a different port for WebClient?

Thanks

Using WC As New WebClient
    If httpAuthentication Then
        WC.Credentials = New NetworkCredential(Me.httpUsername, Me.httpPassword)
    End If
    Dim response As String = WC.DownloadString(Me.uploadUrl)
End Using
Ric
  • 11,643
  • 3
  • 24
  • 35
  • 1
    http://stackoverflow.com/questions/601861/set-timeout-for-webclient-downloadfile this should solve your issue. – Ric Apr 28 '14 at 13:17
  • Thanks for the reply Ric. I've had a read through that but I'm not sure it will solve my issue. The timeout is currently set to infinite, but by the time the server responds port 80 is closed. If I set the timeout to be just less than how long the port is open, won't it just timeout without getting a response? – user3581415 May 09 '14 at 08:43
  • Just Follow This http://stackoverflow.com/questions/16501845/webclient-is-opening-a-new-connection-each-time-i-download-a-file-and-all-of-the – splash xee May 12 '17 at 02:21

0 Answers0