| 19/03/2008 21:18:55 |
|
||
|
Smithy
The Master Administrator * Ultimate Expert * |
Over the past few weeks ive noticed that Internet Explorer tends to lock up when i use a synchronous AJAX request in it. After searching the net i see that other people have had this problem and are confused by it. The strange thing about this problem is that the request never appears to get served. In the code i was working with the request ran a PHP file that updated a database. The database never got updated. To make it even more confusing a lot of people have noticed that if you restart the web server then IE will unlock and return an error. It appears that AJAX never connected yet restarting the web server causes an error. The reason for this problem is a lot simpler than you might think. It is a fact that the request never gets to the web server. The reason for that is because IE limits the amount of sockets it can have open at a time. Other browsers also have a limit but it might be different. IE can only open 2 sockets per domain by default. When your page loads you use 1 socket. If you have pictures on the site too then IE will open a second socket so it can be transfering 2 things at once. When IE has finished downloading a page and all its pictures it keeps both sockets open for a while just incase you click a link. If you click really fast then it will re-use the 2 sockets which are already open. This is where we get the problem with AJAX. If you try to send any AJAX request it seems you must wait for one of these 2 sockets to close. Im not sure why it doesnt just re-use one of them. I think most of the time it does but every so often it waits for one to close. When you send a Synchronous AJAX request the browser is locked until the request completes. Since the request never completes the browser remains locked and it appears that the 2 sockets wont close themselves while the browser is locked either. When you restart your webserver you break the connection to the 2 sockets. The AJAX request immediately tries to connect but fails because the webserver is in the middle of restarting. What can be done about this problem then? Unfortunately not a lot. You could enforce a timelimit to make sure javascript doesnt try to send an AJAX request while the sockets are still open but the timout could be different on each browser and/or server. The method currently being tested at the moment is to load all images, stylesheets and javascript files through a second domain. The browser will allow 2 sockets per domain. On your main domain you use only a single socket for the main page. All other items are loaded through the 2 sockets for the second domain. When your AJAX request is submitted it will use the remaining free socket for the first domain. We are currently experimenting with this to find a more ideal solution to the problem. If anyone has any more info please let me know and we can investigate further. I do believe that there is more to this problem than the socket limit but time will tell.
|
||
| Post Count: 15 |
| Forum Statistics |
|
There are 0 registered users viewing this thread |