I am writing a web application that takes a script input from a client-side browser and sends it to a Java servlet through AJAX. Upon receiving the script, the Java class executes the script and sends some information back to the web page.
An important component of the web application that I am testing right now is the connection timeout and when/if a browser connection will timeout after long periods of time. For me, it is important that the connection does NOT timeout before the Java servlet sends a response, or at least the timeout should be handled.
I have researched ways of handling this and I have a vague understanding of what needs to be done, but first thing is first, I decided to try to get the connection to timeout in order to understand how everything will behave WITHOUT any sort of error handling. Yesterday, I sent the servlet a command from the script input of the client-side which told the servlet to sleep until this morning. I come back this morning to find that in Chrome, the servlet response was successfully received and happily showing itself in the browser.
In IE7, I did not have as much luck 🙁
After over 15 hours of waiting on a response, IE7 timed out and Chrome did not. I figured either both would time out or neither would.
Also, it might be helpful to know that I am using Struts2 framework.
Can anyone explain this?
Thanks!
P.S. I tried to be as detailed as I could in my question explanation, but I will be happy to include any extra information. I also did not include code, because I did not think any would be relevant, but again, please tell me what code you’d want me to include if you’d like to see some.
Turns out that Chrome is just awesome and IE is not (surprise!). Here’s what I am pretty sure happened:
On the ajax call, since no timeout was set, Chrome let the timeout default to 0 i.e. never timeout.
IE7 being the obnoxious browser that it is (and unfortunately the one I MUST develop for), didn’t want that to happen, so it stuck with its registry-set default timeout of 60 minutes.
JQuery and AJAX made handling this error a breeze with a bit of longpolling, or at least what I understand to be longpolling. Here’s what I did:
Initial AJAX Request (contained in a function):
Longpolling(?)
}
This works! One thing I noticed, however, is IE7 returns a textStatus of “error” on a timeout instead of “timeout”… odd!