Jaanus
Jaanus

Reputation: 16541

HttpWebRequest giving me timed out at random times

My application is running whole night and at random times it gets disconnected, on the other hand on some nights it does not.

This is the exeption in Visual Studio, it gets stuck in here. enter image description here

This is the info it gives about my WebRequest. enter image description here This is the info it gives about the exception on response. enter image description here

What I am thinking, is that it is not my bug, sometimes really server does not answer me and it is giving me this exception. If you agree, how would it best to handle this kind of exception. Should i just wrap my 3 using statements into try catch?

Upvotes: 0

Views: 112

Answers (1)

Cameron
Cameron

Reputation: 98746

Yup, try-catch is the way to go for unreliable web services (and perhaps a loop to try again a limited number of times).

Note that you can stack your using statements this way to avoid all the indentation:

using (...)
using (...)
using (...) {
    // Do stuff...
}

Upvotes: 1

Related Questions