XMLHTTP async

V

Vanessa

I have a question regarding async mode for calling Microsoft.XMLHTTP object.

Microsoft.XMLHTTP hangs the IE once in a while suddenly, but it will work
again after half an hour or so without doing anything. I have searched
through the Internet and seems like the reason it hangs the browser it's
because XMLHTTP limits you to two concurrent HTTP connections to each remote
host; so if more than 2 concurrent connections strike the script which is
calling XMLHTTP, it will hang. Is that true?

If that the case, can I change async mode to true (async=true) so that it
will only take one connection at a time, meanwhile other concurrent
connections will loop and wait till XMLHTTP is ready to process data again.
Will that work?

Please help me cause I am not sure whether my impression is correct or not.
Thanks!
 
M

Mark J. McGinty

Vanessa said:
I have a question regarding async mode for calling Microsoft.XMLHTTP
object.

Microsoft.XMLHTTP hangs the IE once in a while suddenly, but it will work
again after half an hour or so without doing anything. I have searched
through the Internet and seems like the reason it hangs the browser it's
because XMLHTTP limits you to two concurrent HTTP connections to each
remote
host; so if more than 2 concurrent connections strike the script which is
calling XMLHTTP, it will hang. Is that true?

Are you talking about using XMLHTTP in server-side ASP code, or client-side
script [emitted from ASP, but executed by IE]?

If the former, you should be using XMLHTTPServer -- but note that with
either object, you cannot call another ASP in the same virtual directory as
the calling ASP. (Doing so will hang the virtual server.)

If the latter, try adding the "defer" attribute to your script tags (<script
defer>) which will defer execution until after the page has completely
loaded.

In neither case is async operation likely to be extremely useful, I've never
managed to get XMLHTTP events to work quite right in HTML script, and on the
server side, ASP doesn't lend itself to async calls at all. You'll use more
CPU looping on a readystate check than waiting for the call to complete --
particularly without a native way to "sleep" the calling process.

What's more, async calls would be more likely to incur more connections, not
less likely (given a single-threaded environment like ASP script.)

Lastly, 30 minutes is an awfully long time to hang, so it would seem at
least a little deeper than the connection limit.


-Mark
 
V

Vanessa

I am talking about using XMLHTTP in server-side ASP code. However, I have
tried using ServerXMLHTTP, namely MSXML2.ServerXMLHTTP object, in replace of
Microsoft.XMLHTTP. Sometimes it works perfectly fine but sometimes it gives
me time out error, which gave me a headache:
msxml3.dll error '80072ee2'
The operation timed out

For using XMLHTTP, my two asp pages are in different virtual directories.
The calling asp page will call XMLHTTP object to get some data dynamically
from other asp page and then display information to the IE. Hm.. so setting
async to true will not help in this issue...

If two asp pages are in the same virtual directory, will it hang IE all the
times or just once in a while? And once it hangs, do we have to restart the
IIS in order to work again or we can just wait? Cause in my situation, it
will hang just once in a while. Thanks!!

Vanessa

Mark J. McGinty said:
Vanessa said:
I have a question regarding async mode for calling Microsoft.XMLHTTP
object.

Microsoft.XMLHTTP hangs the IE once in a while suddenly, but it will work
again after half an hour or so without doing anything. I have searched
through the Internet and seems like the reason it hangs the browser it's
because XMLHTTP limits you to two concurrent HTTP connections to each
remote
host; so if more than 2 concurrent connections strike the script which is
calling XMLHTTP, it will hang. Is that true?

Are you talking about using XMLHTTP in server-side ASP code, or client-side
script [emitted from ASP, but executed by IE]?

If the former, you should be using XMLHTTPServer -- but note that with
either object, you cannot call another ASP in the same virtual directory as
the calling ASP. (Doing so will hang the virtual server.)

If the latter, try adding the "defer" attribute to your script tags (<script
defer>) which will defer execution until after the page has completely
loaded.

In neither case is async operation likely to be extremely useful, I've never
managed to get XMLHTTP events to work quite right in HTML script, and on the
server side, ASP doesn't lend itself to async calls at all. You'll use more
CPU looping on a readystate check than waiting for the call to complete --
particularly without a native way to "sleep" the calling process.

What's more, async calls would be more likely to incur more connections, not
less likely (given a single-threaded environment like ASP script.)

Lastly, 30 minutes is an awfully long time to hang, so it would seem at
least a little deeper than the connection limit.


-Mark

If that the case, can I change async mode to true (async=true) so that it
will only take one connection at a time, meanwhile other concurrent
connections will loop and wait till XMLHTTP is ready to process data
again.
Will that work?

Please help me cause I am not sure whether my impression is correct or
not.
Thanks!
 
M

Mark J. McGinty

Vanessa said:
I am talking about using XMLHTTP in server-side ASP code. However, I have
tried using ServerXMLHTTP, namely MSXML2.ServerXMLHTTP object, in replace
of
Microsoft.XMLHTTP. Sometimes it works perfectly fine but sometimes it
gives
me time out error, which gave me a headache:
msxml3.dll error '80072ee2'
The operation timed out

That beats hanging IE for half an hour, doesn't it? :) You could trap the
error and retry, but the core issue would be whatever's causing it to
timeout. Is there any chance the underlying SQL is deadlocking? When the
condition occurs again, use Enterprise Manager -> Management -> Current
Activity -> Process Info, or execute sp_who2 in Query Analyzer, to check for
any blocking processes.

That assumes, of course, you're using SQL Server as the database back-end.
If not, deadlock is still the avenue I would pursue, but I don't know enough
about Oracle or MySQL (and don't care enough about Jet) to offer any real
help.
For using XMLHTTP, my two asp pages are in different virtual directories.
The calling asp page will call XMLHTTP object to get some data dynamically
from other asp page and then display information to the IE. Hm.. so
setting
async to true will not help in this issue...

If two asp pages are in the same virtual directory, will it hang IE all
the
times or just once in a while? And once it hangs, do we have to restart
the
IIS in order to work again or we can just wait? Cause in my situation, it
will hang just once in a while. Thanks!!

Caller and callee in the same virtual dir will hang IIS every time; IE also
appears to hang but that's more of a side-effect than anything else. I
personally have never been patient enough to wait that long for a hung
process. IIS may do something to self-correct eventually, but I always
end-up resetting it myself long before that occurs. :)

Vanessa

Mark J. McGinty said:
Vanessa said:
I have a question regarding async mode for calling Microsoft.XMLHTTP
object.

Microsoft.XMLHTTP hangs the IE once in a while suddenly, but it will
work
again after half an hour or so without doing anything. I have searched
through the Internet and seems like the reason it hangs the browser
it's
because XMLHTTP limits you to two concurrent HTTP connections to each
remote
host; so if more than 2 concurrent connections strike the script which
is
calling XMLHTTP, it will hang. Is that true?

Are you talking about using XMLHTTP in server-side ASP code, or
client-side
script [emitted from ASP, but executed by IE]?

If the former, you should be using XMLHTTPServer -- but note that with
either object, you cannot call another ASP in the same virtual directory
as
the calling ASP. (Doing so will hang the virtual server.)

If the latter, try adding the "defer" attribute to your script tags
(<script
defer>) which will defer execution until after the page has completely
loaded.

In neither case is async operation likely to be extremely useful, I've
never
managed to get XMLHTTP events to work quite right in HTML script, and on
the
server side, ASP doesn't lend itself to async calls at all. You'll use
more
CPU looping on a readystate check than waiting for the call to
complete --
particularly without a native way to "sleep" the calling process.

What's more, async calls would be more likely to incur more connections,
not
less likely (given a single-threaded environment like ASP script.)

Lastly, 30 minutes is an awfully long time to hang, so it would seem at
least a little deeper than the connection limit.


-Mark

If that the case, can I change async mode to true (async=true) so that
it
will only take one connection at a time, meanwhile other concurrent
connections will loop and wait till XMLHTTP is ready to process data
again.
Will that work?

Please help me cause I am not sure whether my impression is correct or
not.
Thanks!
 
V

Vanessa

Mark,

Yes! If the time out error occurs from using ServerXMLHTTP, it hangs for
half an hour or so too! :( It's like if I used XMLHTTP, it just hangs IE
with no error message. If I used ServerXMLHTTP, it will give me time out
error. For both cases, it doesn't occur all the times and I have to wait for
half an hour or so for it to be back up again. But too bad I can't simply
restart IIS cause we have so many users connect to it. So if it's not the
last thing we can do to fix the problem, we can't restart it! :(

So Mark, how can I trap the error and retry? Is that using On Error resume
next statement? I think I tried it before but seems like doesn't work or so.
Here is my code calling XMLHTTP:
Response.Buffer = True
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
'Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
'xml.setTimeouts 60000, 60000, 60000, 60000
xml.Open "POST", PostURL, False,"",""
xml.Send
FOBprice = xml.responseText
Set xml = Nothing

and yes, I am using SQL Server and thanks for the tips on checking deadlock
situation! I will definitely look it up if this condition occurs again! So
if it occurs again, will the status for that particular process show
"deadlock"? If yes, can I kill that process and the problem will be fixed?

Thanks again and again :)

Vanessa

Mark J. McGinty said:
Vanessa said:
I am talking about using XMLHTTP in server-side ASP code. However, I have
tried using ServerXMLHTTP, namely MSXML2.ServerXMLHTTP object, in replace
of
Microsoft.XMLHTTP. Sometimes it works perfectly fine but sometimes it
gives
me time out error, which gave me a headache:
msxml3.dll error '80072ee2'
The operation timed out

That beats hanging IE for half an hour, doesn't it? :) You could trap the
error and retry, but the core issue would be whatever's causing it to
timeout. Is there any chance the underlying SQL is deadlocking? When the
condition occurs again, use Enterprise Manager -> Management -> Current
Activity -> Process Info, or execute sp_who2 in Query Analyzer, to check for
any blocking processes.

That assumes, of course, you're using SQL Server as the database back-end.
If not, deadlock is still the avenue I would pursue, but I don't know enough
about Oracle or MySQL (and don't care enough about Jet) to offer any real
help.
For using XMLHTTP, my two asp pages are in different virtual directories.
The calling asp page will call XMLHTTP object to get some data dynamically
from other asp page and then display information to the IE. Hm.. so
setting
async to true will not help in this issue...

If two asp pages are in the same virtual directory, will it hang IE all
the
times or just once in a while? And once it hangs, do we have to restart
the
IIS in order to work again or we can just wait? Cause in my situation, it
will hang just once in a while. Thanks!!

Caller and callee in the same virtual dir will hang IIS every time; IE also
appears to hang but that's more of a side-effect than anything else. I
personally have never been patient enough to wait that long for a hung
process. IIS may do something to self-correct eventually, but I always
end-up resetting it myself long before that occurs. :)

Vanessa

Mark J. McGinty said:
I have a question regarding async mode for calling Microsoft.XMLHTTP
object.

Microsoft.XMLHTTP hangs the IE once in a while suddenly, but it will
work
again after half an hour or so without doing anything. I have searched
through the Internet and seems like the reason it hangs the browser
it's
because XMLHTTP limits you to two concurrent HTTP connections to each
remote
host; so if more than 2 concurrent connections strike the script which
is
calling XMLHTTP, it will hang. Is that true?

Are you talking about using XMLHTTP in server-side ASP code, or
client-side
script [emitted from ASP, but executed by IE]?

If the former, you should be using XMLHTTPServer -- but note that with
either object, you cannot call another ASP in the same virtual directory
as
the calling ASP. (Doing so will hang the virtual server.)

If the latter, try adding the "defer" attribute to your script tags
(<script
defer>) which will defer execution until after the page has completely
loaded.

In neither case is async operation likely to be extremely useful, I've
never
managed to get XMLHTTP events to work quite right in HTML script, and on
the
server side, ASP doesn't lend itself to async calls at all. You'll use
more
CPU looping on a readystate check than waiting for the call to
complete --
particularly without a native way to "sleep" the calling process.

What's more, async calls would be more likely to incur more connections,
not
less likely (given a single-threaded environment like ASP script.)

Lastly, 30 minutes is an awfully long time to hang, so it would seem at
least a little deeper than the connection limit.


-Mark


If that the case, can I change async mode to true (async=true) so that
it
will only take one connection at a time, meanwhile other concurrent
connections will loop and wait till XMLHTTP is ready to process data
again.
Will that work?

Please help me cause I am not sure whether my impression is correct or
not.
Thanks!
 
M

Mark J. McGinty

Vanessa said:
Mark,

Yes! If the time out error occurs from using ServerXMLHTTP, it hangs for
half an hour or so too! :( It's like if I used XMLHTTP, it just hangs IE
with no error message. If I used ServerXMLHTTP, it will give me time out
error. For both cases, it doesn't occur all the times and I have to wait
for
half an hour or so for it to be back up again. But too bad I can't simply
restart IIS cause we have so many users connect to it. So if it's not the
last thing we can do to fix the problem, we can't restart it! :(

So Mark, how can I trap the error and retry? Is that using On Error resume
next statement? I think I tried it before but seems like doesn't work or
so.

Yes, you've got it... there are some untrappable errors but anything that's
thrown by a COM object should trap. Then after Send returns, test the Err
object:
Here is my code calling XMLHTTP:
Response.Buffer = True
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
'Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
'xml.setTimeouts 60000, 60000, 60000, 60000
xml.Open "POST", PostURL, False,"",""

On Error Resume Next

If Err.Number > 0 Then ' you may want to test for a specific error value
' do something here to retry, maybe wrap the XML call in a function and
call it here
End If

On Error Goto 0 ' turn errors back on
FOBprice = xml.responseText
Set xml = Nothing

and yes, I am using SQL Server and thanks for the tips on checking
deadlock
situation! I will definitely look it up if this condition occurs again!
So
if it occurs again, will the status for that particular process show
"deadlock"? If yes, can I kill that process and the problem will be fixed?

In Enterprise Manager Process Info there are the columns Blocking and
Blocked By, that give you the involved process IDs. You're looking for one
that's got a number in Blocked By. Double-click the item in the list and
usually it will show you the last SQL statement executed by the process.
Click the kill button, game over.

In Query Analyzer, the results of sp_who2 have a BlkBy column, and you can
execute the KILL command to kill a process.

Good Luck! :)

-Mark


Thanks again and again :)

Vanessa

Mark J. McGinty said:
Vanessa said:
I am talking about using XMLHTTP in server-side ASP code. However, I
have
tried using ServerXMLHTTP, namely MSXML2.ServerXMLHTTP object, in
replace
of
Microsoft.XMLHTTP. Sometimes it works perfectly fine but sometimes it
gives
me time out error, which gave me a headache:
msxml3.dll error '80072ee2'
The operation timed out

That beats hanging IE for half an hour, doesn't it? :) You could trap
the
error and retry, but the core issue would be whatever's causing it to
timeout. Is there any chance the underlying SQL is deadlocking? When
the
condition occurs again, use Enterprise Manager -> Management -> Current
Activity -> Process Info, or execute sp_who2 in Query Analyzer, to check
for
any blocking processes.

That assumes, of course, you're using SQL Server as the database
back-end.
If not, deadlock is still the avenue I would pursue, but I don't know
enough
about Oracle or MySQL (and don't care enough about Jet) to offer any real
help.
For using XMLHTTP, my two asp pages are in different virtual
directories.
The calling asp page will call XMLHTTP object to get some data
dynamically
from other asp page and then display information to the IE. Hm.. so
setting
async to true will not help in this issue...

If two asp pages are in the same virtual directory, will it hang IE all
the
times or just once in a while? And once it hangs, do we have to
restart
the
IIS in order to work again or we can just wait? Cause in my situation,
it
will hang just once in a while. Thanks!!

Caller and callee in the same virtual dir will hang IIS every time; IE
also
appears to hang but that's more of a side-effect than anything else. I
personally have never been patient enough to wait that long for a hung
process. IIS may do something to self-correct eventually, but I always
end-up resetting it myself long before that occurs. :)

Vanessa

:


I have a question regarding async mode for calling Microsoft.XMLHTTP
object.

Microsoft.XMLHTTP hangs the IE once in a while suddenly, but it will
work
again after half an hour or so without doing anything. I have
searched
through the Internet and seems like the reason it hangs the browser
it's
because XMLHTTP limits you to two concurrent HTTP connections to
each
remote
host; so if more than 2 concurrent connections strike the script
which
is
calling XMLHTTP, it will hang. Is that true?

Are you talking about using XMLHTTP in server-side ASP code, or
client-side
script [emitted from ASP, but executed by IE]?

If the former, you should be using XMLHTTPServer -- but note that with
either object, you cannot call another ASP in the same virtual
directory
as
the calling ASP. (Doing so will hang the virtual server.)

If the latter, try adding the "defer" attribute to your script tags
(<script
defer>) which will defer execution until after the page has completely
loaded.

In neither case is async operation likely to be extremely useful, I've
never
managed to get XMLHTTP events to work quite right in HTML script, and
on
the
server side, ASP doesn't lend itself to async calls at all. You'll
use
more
CPU looping on a readystate check than waiting for the call to
complete --
particularly without a native way to "sleep" the calling process.

What's more, async calls would be more likely to incur more
connections,
not
less likely (given a single-threaded environment like ASP script.)

Lastly, 30 minutes is an awfully long time to hang, so it would seem
at
least a little deeper than the connection limit.


-Mark


If that the case, can I change async mode to true (async=true) so
that
it
will only take one connection at a time, meanwhile other concurrent
connections will loop and wait till XMLHTTP is ready to process data
again.
Will that work?

Please help me cause I am not sure whether my impression is correct
or
not.
Thanks!
 
V

Vanessa

Thanks Mark!
I will try both. Thanks for your help :)

Mark J. McGinty said:
Vanessa said:
Mark,

Yes! If the time out error occurs from using ServerXMLHTTP, it hangs for
half an hour or so too! :( It's like if I used XMLHTTP, it just hangs IE
with no error message. If I used ServerXMLHTTP, it will give me time out
error. For both cases, it doesn't occur all the times and I have to wait
for
half an hour or so for it to be back up again. But too bad I can't simply
restart IIS cause we have so many users connect to it. So if it's not the
last thing we can do to fix the problem, we can't restart it! :(

So Mark, how can I trap the error and retry? Is that using On Error resume
next statement? I think I tried it before but seems like doesn't work or
so.

Yes, you've got it... there are some untrappable errors but anything that's
thrown by a COM object should trap. Then after Send returns, test the Err
object:
Here is my code calling XMLHTTP:
Response.Buffer = True
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
'Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
'xml.setTimeouts 60000, 60000, 60000, 60000
xml.Open "POST", PostURL, False,"",""

On Error Resume Next

If Err.Number > 0 Then ' you may want to test for a specific error value
' do something here to retry, maybe wrap the XML call in a function and
call it here
End If

On Error Goto 0 ' turn errors back on
FOBprice = xml.responseText
Set xml = Nothing

and yes, I am using SQL Server and thanks for the tips on checking
deadlock
situation! I will definitely look it up if this condition occurs again!
So
if it occurs again, will the status for that particular process show
"deadlock"? If yes, can I kill that process and the problem will be fixed?

In Enterprise Manager Process Info there are the columns Blocking and
Blocked By, that give you the involved process IDs. You're looking for one
that's got a number in Blocked By. Double-click the item in the list and
usually it will show you the last SQL statement executed by the process.
Click the kill button, game over.

In Query Analyzer, the results of sp_who2 have a BlkBy column, and you can
execute the KILL command to kill a process.

Good Luck! :)

-Mark


Thanks again and again :)

Vanessa

Mark J. McGinty said:
I am talking about using XMLHTTP in server-side ASP code. However, I
have
tried using ServerXMLHTTP, namely MSXML2.ServerXMLHTTP object, in
replace
of
Microsoft.XMLHTTP. Sometimes it works perfectly fine but sometimes it
gives
me time out error, which gave me a headache:
msxml3.dll error '80072ee2'
The operation timed out

That beats hanging IE for half an hour, doesn't it? :) You could trap
the
error and retry, but the core issue would be whatever's causing it to
timeout. Is there any chance the underlying SQL is deadlocking? When
the
condition occurs again, use Enterprise Manager -> Management -> Current
Activity -> Process Info, or execute sp_who2 in Query Analyzer, to check
for
any blocking processes.

That assumes, of course, you're using SQL Server as the database
back-end.
If not, deadlock is still the avenue I would pursue, but I don't know
enough
about Oracle or MySQL (and don't care enough about Jet) to offer any real
help.

For using XMLHTTP, my two asp pages are in different virtual
directories.
The calling asp page will call XMLHTTP object to get some data
dynamically
from other asp page and then display information to the IE. Hm.. so
setting
async to true will not help in this issue...

If two asp pages are in the same virtual directory, will it hang IE all
the
times or just once in a while? And once it hangs, do we have to
restart
the
IIS in order to work again or we can just wait? Cause in my situation,
it
will hang just once in a while. Thanks!!

Caller and callee in the same virtual dir will hang IIS every time; IE
also
appears to hang but that's more of a side-effect than anything else. I
personally have never been patient enough to wait that long for a hung
process. IIS may do something to self-correct eventually, but I always
end-up resetting it myself long before that occurs. :)


Vanessa

:


I have a question regarding async mode for calling Microsoft.XMLHTTP
object.

Microsoft.XMLHTTP hangs the IE once in a while suddenly, but it will
work
again after half an hour or so without doing anything. I have
searched
through the Internet and seems like the reason it hangs the browser
it's
because XMLHTTP limits you to two concurrent HTTP connections to
each
remote
host; so if more than 2 concurrent connections strike the script
which
is
calling XMLHTTP, it will hang. Is that true?

Are you talking about using XMLHTTP in server-side ASP code, or
client-side
script [emitted from ASP, but executed by IE]?

If the former, you should be using XMLHTTPServer -- but note that with
either object, you cannot call another ASP in the same virtual
directory
as
the calling ASP. (Doing so will hang the virtual server.)

If the latter, try adding the "defer" attribute to your script tags
(<script
defer>) which will defer execution until after the page has completely
loaded.

In neither case is async operation likely to be extremely useful, I've
never
managed to get XMLHTTP events to work quite right in HTML script, and
on
the
server side, ASP doesn't lend itself to async calls at all. You'll
use
more
CPU looping on a readystate check than waiting for the call to
complete --
particularly without a native way to "sleep" the calling process.

What's more, async calls would be more likely to incur more
connections,
not
less likely (given a single-threaded environment like ASP script.)

Lastly, 30 minutes is an awfully long time to hang, so it would seem
at
least a little deeper than the connection limit.


-Mark


If that the case, can I change async mode to true (async=true) so
that
it
will only take one connection at a time, meanwhile other concurrent
connections will loop and wait till XMLHTTP is ready to process data
again.
Will that work?

Please help me cause I am not sure whether my impression is correct
or
not.
Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top