473,581 Members | 2,818 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AJAX "crashes" IE on close of Window.

It took me some time to find out when and why this happens.

When the window of Internet Explorer is closed with an AJAX call still
pending, something funny happens. Do it twice, and you will have to
restart the browser.

Here a little sample: http://truefriendz.de/iedos

The script on this site will open 5 test-windows one at a time.

The test-windows will issue an AJAX-Call. This call would only be
answered after 10 seconds, but the windows will be closed before
the answer arrives. (This is not a question of the window.close().
The same would happen if the close is issued by a user closing the
window)

Using IE6/w2k and IE7/vista (and assumedly other versions of IE)
the 3rd and following windows will appear without content. FireFox
performs perfectly well.

I found a workarround, which I regard as clumsy.

<body .... onAbort="cleanu p();" onUnload="clean up();">
function cleanup() { xmlHttp.abort() ;}

Demonstration here: http://truefriendz.de/iedos2

My findings so far: When a window with a pending AJAX-request
ActiveXObject(" Microsoft.XMLHT TP") is closed, a TCP-socket remains
eternally in state close_wait. Check with netstat.

(It seems perfectly normal that sockets enter the state close_wait
(although if I understand the documents correctly this state should
only be entered by SERVERS),
and it seems that sockets can (normally) be reused succesfully from
this state. In "normal operation" such socktes do disappear after a
certain time)

My thoughts: Due to the fact that this Socket is still existing, IE
does
reuse it, but it does not work properly. These Sockets seem
to be damaged somehow.

Funny enough, I did not find any mention of this problem on the web.

Anyone, who can suggest a better, more elegant way to handle this?

Sorry for any mistakes, I did my very best, but I'm not a native
speaker.

May 7 '07 #1
5 13908
So********@goog lemail.com wrote:
It took me some time to find out when and why this happens.

When the window of Internet Explorer is closed with an AJAX call still
pending, something funny happens. Do it twice, and you will have to
restart the browser.

Here a little sample: http://truefriendz.de/iedos

The script on this site will open 5 test-windows one at a time.
Really? In my Internet Explorer 6 it merely says it is opening and
closing windows, but it does not open or close anything.

I do however get:

Line: 39
Char: 2
Error: Object doesn't support this property or method
Code: 0
URL: http://truefriendz.de/iedos/

....5 times.

<snip>

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
May 8 '07 #2
On May 8, 2:51 am, -Lost <maventheextraw o...@techie.com wrote:
The script on this site will open 5 test-windows one at a time.
Really? In my Internet Explorer 6 it merely says it is opening and
closing windows, but it does not open or close anything.
Well, it should, and it *does* on my computer. :)

Thank for giving it a try. The site where this script is hosted is
not mine, so I can do nothing about it *at this site*. But I
made a modified copy here:

http://sommerb.so.funpic.de/ajax/iedos.html

Perhaps this one wil do the Trick. Sorry, this site is not cpmpletely
ad-free, but this was the only PHP-enabled web space I could find
in short time.

I would be very grateful if anybody would have a look at this. I'm
completely at loss, since I found out that even the version *with*
calls to abort() of the AJAX does indeed throw a exception in
FireFox.

TIA

May 8 '07 #3
Just to give more informations:

<head>
var xmlHttp;

function ajax_call(){

//create AJAX.object
xmlHttp = new ActiveXObject(v ersions[idx]);

// Define onreadystatecha nge and issue call to very slow site
xmlHttp.open('G ET', 'response-10s.php', true);
xmlHttp.onready statechange = function () {
if (xmlHttp.readyS tate == 4 && xmlHttp.status == 200) {
alert(xmlHttp.r esponseText);
}
};
xmlHttp.send(nu ll);
}

function cleanup() {
if (xmlHttp) {xmlHttp.abort( )}
}
</head>

<body onLoad="ajax_ca ll();" onAbort="cleanu p();" onUnload="clean up();"
>
....

Without cleanup() this will do damage to Internet-Explorer
(sockets permanently in state close_wait) if the window
is closed with the AJAX still waiting for the response.

Obviously the Ajax doesn't "like" to go into non-existence
without a pending call beeing aborted.

I have very foggy ideas about an Ajax-object that enlists
itself for cleanup...

Somehow to add this cleanup into a chain of operations that are
done automatically on close of the window. I examined some
AJAX-Libraries, but found nothing like that in any of them.

May 8 '07 #4
So********@goog lemail.com wrote:
I would be very grateful if anybody would have a look at this. I'm
completely at loss, since I found out that even the version *with*
calls to abort() of the AJAX does indeed throw a exception in
FireFox.
I do not have the time to peruse your code again, but I can tell you two
things.

1) Depending on your use of your XHR object, abort() is not necessary.
For example, calling the open() method twice on a single XHR object
will reset the object, its connection (what was previously opened/sent),
and will disconnect any event handlers.

2) Firefox does not like the abort() method. Most notably in cases of
use in the onreadystatecha nge event.

NOTE: About the above, it is essential to use abort() in Firefox when
canceling an XHR request, just not in the above mentioned event.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
May 8 '07 #5
So********@goog lemail.com wrote:
>
When the window of Internet Explorer is closed with an AJAX call still
pending, something funny happens. Do it twice, and you will have to
restart the browser.
This sounds like a manifestation of a garbage-collection bug in IE.
When a document references javascript, and the javascript references
back to the document (which is pretty much all the time with AJAX)
then closing the document won't cause the javascript to be terminated.

Furthermore, IE has a very small limit on the number of connections
that it will allow to be simultaneously open to a given site. This
means that when your XmlHttp connections don't terminate, you quickly
run out of connections. This leaves you stuck until the XmlHttp
connections time out, which can take several minutes.

It's a pain in the ass. IE has had this bug for years. I don't know
if the newest version of IE still has the bug, but you have to plan
for the worst -- assume IE always has the bug.

See http://www.litotes.demon.co.uk/examp...finalizer.html
for more on the problem, and one possible solution.

Another technique which I've read about BUT NEVER TRIED is to use
different names for the server, so you increase the number of possible
connections. For example, supposedly "google.com " and "www.google.com "
will have separate connection pools even if they reference the same
site. The reason I never tried this technique is that it seems like
it'd take a lot of intricate site-specific engineering to make it
work reliably.
May 9 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2799
by: f.ruecker | last post by:
Hey Folks, I hope you'll be nice to me and let this post go through even know its mysql and not directly php. But of course my script is php. The problem is, that my Table (1,8 MIO entries/100 MB/MyISAM) is not working anymore. Everytime my script wants to write in something the number of entries decreases, and at the "Overhead" column the...
24
4472
by: sinister | last post by:
After doing a websearch, it appears that it's OK to omit the "http:" to form a relative URL. Are there any pitfalls to this? For example, if there is a page http://www.domain1.com/page1.html with a link to http://www.domain2.com/page2.html you can abbreviate the second link as //www.domain2.com/page2.html
6
2114
by: (Pete Cresswell) | last post by:
I'm makeing a little DB to help manage high school class reunions. One feature I'm trying to implement is "Friends". e.g. Fred Smith is a friend of Joe Jones and Bill Anderson. We record that so that when Fred moves and our mailing bounces, we can call Joe and/or Bill in hopes of getting Fred's new address. I started implementing...
5
4410
by: _BNC | last post by:
I've converted " byte" to "byte *" at times, using 'unsafe' and fixed { .... }, but the reverse does not seem to work. In this case, a C++ DLL returns a byte * and a length. What is the best way to convert these to straight C#-compatible straight " byte" arrays? PS: The C++ DLL is actually managed and I have access to the source....
7
2611
by: Simon Verona | last post by:
I have a problem in my application which I believe is due to open handles.. . The symptom that users report is that after they have been using the application for a while, it will randomly just crash with an exception report (I've not got the details of the error, but I'm working on that now!). I'm trying to reproduce the circumstances by...
3
2903
by: Jerry | last post by:
I have created an application using wxPython and compiled it using py2exe. When I put setup(console=) in my setup.py file, the resulting application runs just fine. But when I change it to setup(windows=)
10
10028
by: morangolds | last post by:
Hi, I've been having a problem with C++ Windows Forms apps not "ending" when you close the form window. I've searched about this problem all over the place and most searches have lead me to believe that this has to do with unreleased form component events or event handlers. I'm comparatively new to .net and windows forms, in the sense that...
1
1311
by: Toni | last post by:
Hello! I have a problem that I hope someone could help me with. Recently a web application was ordered from a software developer and installed on the server of my working place. This application uses a web service that runs on the same server. My job was to make changes to a couple of forms which were then put to the server to replace existing...
9
3353
by: andrew.smith.cpp | last post by:
hi, whts the difference between the std::endl or "\n" ? because both do the same work Thanks
0
7883
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7917
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6567
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5685
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3835
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1413
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.