FAQ for the Http Request (WinHTTP v5.0) sample:
Sometimes the sample takes a long time to return. Is there a way to reduce the waiting time?
Delays are usually caused by network congestion or the remote server being temporarily unavailable. You can set the time for the component to wait for a reply by using the SetTimeouts method:
objWinHttp.SetTimeouts 5000, 10000, 10000, 10000
You'll notice it takes 4 parameters: ResolveTimeout, ConnectTimeout, SendTimeout, and ReceiveTimeout. All 4 are required and are expressed in milliseconds (1000 = 1 second). The defaults are:
ResolveTimeout: zero (no time out)
ConnectTimeout: 60,000 (one minute)
SendTimeout: 30,000 (30 secs.)
ReceiveTimeout: 30,000 (30 secs.)
It should be noted that the Send and Receive timeouts are per packet, so for larger responses (which are split into multiple packets) the timeouts are checked for each packet.
If any of the timeouts is reached, an "operation timed out" error is thrown and should be handled.
Okay... so I'm supposed to handle those operation timed out errors. How?
Funny you should ask... we happen to have a sample script that shows you just how to do that.
HTTP Request Timeout Sample
So you're using ASP.NET... no problem. Here's a ASP.NET version that illustrates how to
set timeouts and handle the error that is thrown when the remote server doesn't
respond quickly enough.
Handling HTTP Request Timeouts in ASP.NET
It's not much to look at, but you can also
view the source code which should be a little more helpful.
Was your question not answered above?
Ask a new question
Please note: This form is only for submitting questions about the sample for us to consider including in the FAQ. If we feel the question merits inclusion, we will include it along with a reply. We will not respond to your email individually.