I implemented a long polling connection to allow me to do a server-side comet push using the Tomcat web server and standard javascript on the interface. To maintain a connection, I have a simple keep-alive loop that initiates a new request as soon as the last one completes / shuts down.
The vast majority of the time, this relationship works just fine and persists as I expect. But I noticed that when the user Internet connection drops out (for example, they disconnect from the VPN, disconnect their ethernet, etc.) And I have a pending XMLHttpRequest on the server, I do not see any signs of failure. Because of this, the connection freezes silently, and I canβt know what happened if I constantly send requests to the server to check the connection (which does not seem to allow a long poll).
Here's the request object that I see in Chrome when it dies this silent death:
request: XMLHttpRequest onabort: function () onerror: function () onload: null onloadend: null onloadstart: null onprogress: null onreadystatechange: function () readyState: 1 response: "" responseText: "" responseType: "" responseXML: null status: [Exception: DOMException] statusText: [Exception: DOMException] upload: XMLHttpRequestUpload withCredentials: false
I have three listening methods (onabort, onerror, onreadystatechange) to alert the message if they ever fire, but I get nothing when I take my connection to the server. This is how I form the request:
var request = new XMLHttpRequest();
It seems like this would be a pretty standard situation, but I have not seen any talk about how to allow a long voice connection to recover from such disconnections.
Am I doing something wrong? Is there an even more standard approach to long polling / comets that circumvents this problem?
Any help with this would be greatly appreciated. Thanks
dallas
source share