Walt Welton-Lair
2005-04-26 04:22:02 UTC
I'm running into a problem which I believe involves mixing of asynchronous /
synchronous requests. Here's the scenario. Using IE I make a server
request which responds with some DHTML containing a number of HREFs, plus an
object tag referencing my ActiveX control. The control downloads content
from a location specified by a parameter in the object tag, and it uses
synchronous calls to WinInet to do this.
The problem I'm having is that the control's request times out. This is
what I see happening:
- the DHTML loads in IE, including the reference to the control
- IE begins resolving HREFs
=> there are lots of them, so all available connections get used
(MaxConnectionsPerServer is set to its default of 2)
- the control initializes itself and makes its synchronous request via
WinInet (same process as IE)
=> at this point all loading in IE halts
- eventually the control's request times out
- immediately IE continues loading the remaining HREFs
If I set MaxConnectionsPerServer to a large enough value (e.g. > the number
of HREFs) then everything works fine.
I read the Microsoft support article at
http://support.microsoft.com/kb/q183110/. It states:
"WinInet limits the number of simultaneous connections that it makes to a
single HTTP server. If you exceed this limit, the requests block until one
of the current connections has completed."
So the control's request is definitely getting blocked - no big deal. But
as I mentioned above, all activity in the current connections is temporarily
suspended once the control's (synchronous) request is made. Unfortunately
that means none of the current connections ever completes so that the
control's request can become unblocked. The control will always timeout in
this case.
These observations suggest that a synchronous WinInet request blocks all
asynchronous requests made from the same process. Can someone confirm this?
As far as how to address my problem, I know I can call InternetSetOption and
programmatically increase MaxConnectionsPerServer, but I don't like that for
two reasons:
- I'll never know in advance how many connections I'll need
- it generally doesn't seem like a good idea to stray from the HTTP
specification
Does anyone know of other simple workarounds for this? Or do I have no
choice but to update the control to make an asynchronous request?
Thanks in advance for any feedback.
Walt
synchronous requests. Here's the scenario. Using IE I make a server
request which responds with some DHTML containing a number of HREFs, plus an
object tag referencing my ActiveX control. The control downloads content
from a location specified by a parameter in the object tag, and it uses
synchronous calls to WinInet to do this.
The problem I'm having is that the control's request times out. This is
what I see happening:
- the DHTML loads in IE, including the reference to the control
- IE begins resolving HREFs
=> there are lots of them, so all available connections get used
(MaxConnectionsPerServer is set to its default of 2)
- the control initializes itself and makes its synchronous request via
WinInet (same process as IE)
=> at this point all loading in IE halts
- eventually the control's request times out
- immediately IE continues loading the remaining HREFs
If I set MaxConnectionsPerServer to a large enough value (e.g. > the number
of HREFs) then everything works fine.
I read the Microsoft support article at
http://support.microsoft.com/kb/q183110/. It states:
"WinInet limits the number of simultaneous connections that it makes to a
single HTTP server. If you exceed this limit, the requests block until one
of the current connections has completed."
So the control's request is definitely getting blocked - no big deal. But
as I mentioned above, all activity in the current connections is temporarily
suspended once the control's (synchronous) request is made. Unfortunately
that means none of the current connections ever completes so that the
control's request can become unblocked. The control will always timeout in
this case.
These observations suggest that a synchronous WinInet request blocks all
asynchronous requests made from the same process. Can someone confirm this?
As far as how to address my problem, I know I can call InternetSetOption and
programmatically increase MaxConnectionsPerServer, but I don't like that for
two reasons:
- I'll never know in advance how many connections I'll need
- it generally doesn't seem like a good idea to stray from the HTTP
specification
Does anyone know of other simple workarounds for this? Or do I have no
choice but to update the control to make an asynchronous request?
Thanks in advance for any feedback.
Walt