Question Web Client timeout?

LeonLanford

Active member
Joined
Dec 2, 2008
Messages
28
Programming Experience
Beginner
Hi.. I'm making program to read txt file from website by using system.net.webclient, It can work perfectly in localhost, but when I tried at the hosting, it got timeout after second or third request at
VB.NET:
strem = WC.OpenRead(alamat_txt)

I thought the program hang, but after 2 minutes it shows error message saying timeout.. I must close the program and open it again, if I don't close the program, the remote txt file will cannot be opened again..
Is there something I can do to prevent the timout or prevent from reopening the program again to open the remote file?

Here's the code and screenshot..

VB.NET:
       Try
            Using WC As New System.Net.WebClient()
                WC.OpenRead(alamat_view)
                strem = WC.OpenRead(alamat_txt)

            Using reader As New System.IO.StreamReader(strem)
                WC.OpenRead(alamat_view)
                strem = WC.OpenRead(alamat_txt)
                Dim line As String = String.Empty
                While reader.Peek >= 0
                    line = reader.ReadLine()
                End While
            End Using
        End Using

        Catch ex As Exception
            MessageBox.Show("Server is busy.. Please try again")
        End Try

11hug5t.jpg


Thanks..
 
Back
Top