I am using HttpWebRequest
in my application which is checking some URI\'s in multiple threads. I am getting multiple types of time out exceptions.
The operation has timed out is a client error. It is usually caused by various *Timeout
properties of WebRequest
(and its descendants): Timeout
, ContinueTimeout
, ReadWriteTimeout
. If the server you sent request to does not respond within the timeout you set, you get TimeoutException
.
To avoid this error, you can increase timeouts. However, they are quite big by default, so increasing is unlikely to help. You can try several times. If it doesn't help, the server is probably down.
504 Gateway Timeout is a server error. It is usually caused by errors in or overloading of the server infrastructure you sent requests to. It is black box for you.
You can't do anything about this error, only server administrators can resolve that. If the error is caused by overloading, you can try requesting several times, but doing this too often will do more harm than good, obviously.
In general, if you don't get an HTTP code, it's an exception from .NET. If you do get an HTTP code, you can look at the first digit:
2**
OK
3**
Redirection
4**
Client error
5**
Server error