Long Poll Object and XDomainRequest IE

I am trying to implement a chat application that uses a lengthy poll to receive messages from a remote server (cross-domain).

Is there a way to do this using XDomainRequest? It seems that my connections always end after a random number of seconds / milliseconds (usually about 1-3 seconds), and do not wait for a server response.

IE dev toools thell to me that the request was "aborted" without receiving data.

Is XDomainRequest just not suitable for a lengthy survey, or am I not seeing something here?

+4
source share
2 answers

Was this problem also as a race condition using the jQuery iecors library. The IE Network Console showed the request as an β€œinterrupt”, even though Fiddler showed a 200 response.

After several stubborn rounds of searching on Google, I came across this link, which recommends filling in all callback handlers. I suspect that onProgress was only called and failed when the request was slowed down by a heavy page, which led to my behavior.

Issued IE9 XDomainRequest Requests May Abort If All Event Handlers Not Specified

For jquery.iecors.js, it lacked an onprogress handler, as well as several typos of the variable name. Adding this line seems to fix it.

xdr.onprogress = function () {}; 
+4
source

For me, the problem concerned several query functions that work as a single batch function using XDomainRequests. WebTools showed that all requests to the remote server are interrupted, but the last. Work with a warning (request) before each request. Therefore, I moved the XDR call (for example, new window.XDomainRequest) inside the loop so that a new instance is created for each request to the remote server. Each result is entered into a different input field via getElementById (id) .value. With the addition of a delay timer, I see that it starts sequentially, filling each value without problems. Without delay, it is almost instant.

+2
source

All Articles