HttpWebRequest: Timeout and ReadWriteTimeout

In NETCF V1, when a HttpWebRequest fails due to a timeout, a WebException is thrown with this exception message:

System.Net.WebException: The operation has timed-out.

This means that the request cannot be completed within the timeout value, which can be set through the Timeout property in HttpWebRequest. The default value for this Timeout property is 100 seconds.

In .NET CF 2.0, we added another property called ReadWriteTimeout to provide developers with a way to control how long a single Read or Write operation can take. The default value for this property is 300 seconds, or 5 minutes.

When a Read or Write operation fails due to a read-write timeout, a SocketException is thrown:

System.Net.Sockets.SocketException: An operation was attempted on something that is not a socket

Since this message is a generic exception message that is shown for issues other than a read-write timeout as well, it is important to examine the cause of the exception when a SocketException occurs. A stack trace and network log are useful here. .NET CF 2.0 provides network logging capability to facilitate the debugging of network issues on device. We are working hard to get the log reader tool released.



This posting is provided "AS IS" with no warranties, and confers no rights.