-
-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Misfire of the polling request #1261
Comments
The clearTimeout() is from function _timeout(). |
Hey, Jeanfrancois, From my observation, I guess the root cause might be as the following. When the polling request returns, it schedules the next poll using setTimeout(function() {
_executeRequest(request);
}, 0); Which is to fire the next polling request immediately after this polling returns. More specifically, after the current thread returns, since JS is single threaded by nature. This happens if incoming message interlays with the sending message. I guess the scheduling of the thread is not guaranteed even if we specifies it to timeout in 0 ms. Let me know what you think. Thanks! |
Hi, Jeanfrancois, I setup a small application in which the client sends a message to itself. // My request
var ch = messagingAgent.subscribe('1');
ch.onMessage = function(message) {
console.log(message);
};
// Console outputs
readyState: 2 jquery.atmosphere.js:1504
clearing timeout in _timeout() jquery.atmosphere.js:1222
readyState: 3 jquery.atmosphere.js:1504
clearing timeout in _timeout() jquery.atmosphere.js:1222
readyState: 4 jquery.atmosphere.js:1504
clearing timeout in _timeout() jquery.atmosphere.js:1222
isAllowedToReconnect: true jquery.atmosphere.js:1606
rq.executeCallbackBeforeReconnect: false jquery.atmosphere.js:1607
reconnecting ... jquery.atmosphere.js:1610
before setTimeout for _executeRequest jquery.atmosphere.js:1712
before _executeRequest jquery.atmosphere.js:1714
// My request
ch.send(1, "1");
readyState: 2 jquery.atmosphere.js:1504
clearing timeout in _timeout() jquery.atmosphere.js:1222
readyState: 4 jquery.atmosphere.js:1504
clearing timeout in _timeout() jquery.atmosphere.js:1222
readyState: 2 jquery.atmosphere.js:1504
clearing timeout in _timeout() jquery.atmosphere.js:1222
readyState: 3 jquery.atmosphere.js:1504
clearing timeout in _timeout() jquery.atmosphere.js:1222
readyState: 4 jquery.atmosphere.js:1504
clearing timeout in _timeout() jquery.atmosphere.js:1222
isAllowedToReconnect: true jquery.atmosphere.js:1606
rq.executeCallbackBeforeReconnect: false jquery.atmosphere.js:1607
reconnecting ... jquery.atmosphere.js:1610
before setTimeout for _executeRequest jquery.atmosphere.js:1712
1
before _executeRequest jquery.atmosphere.js:1714
// My request
ch.send(1, "1");
// Console outputs
readyState: 2 jquery.atmosphere.js:1504
clearing timeout in _timeout() jquery.atmosphere.js:1222
readyState: 3 jquery.atmosphere.js:1504
clearing timeout in _timeout() jquery.atmosphere.js:1222
readyState: 4 jquery.atmosphere.js:1504
clearing timeout in _timeout() jquery.atmosphere.js:1222
isAllowedToReconnect: true jquery.atmosphere.js:1606
rq.executeCallbackBeforeReconnect: false jquery.atmosphere.js:1607
reconnecting ... jquery.atmosphere.js:1610
before setTimeout for _executeRequest jquery.atmosphere.js:1712
1
readyState: 2 jquery.atmosphere.js:1504
clearing timeout in _timeout() jquery.atmosphere.js:1222 // RECONNECT REQUEST IS KILLED HERE!
readyState: 4 jquery.atmosphere.js:1504
clearing timeout in _timeout() jquery.atmosphere.js:1222
clearing timeout in _clearState() jquery.atmosphere.js:2403 |
Hey, you need to try 1.0,16. I think this has been fixed. Pull the latest version from here and let me know. |
OK I was never able to reproduce the issue, but pushed a fix here. Try this version it should now works. |
I am using Atmosphere 1.0.15. I build my application on top of the Jersey pub-sub sample using long-polling.
I noticed a tricky issue of miss fire of the polling request. I did some troubleshooting and noticed that from "jquery.atmosphere.js", the
function _reconnect(ajaxRequest, request, reconnectInterval);
has the following logic,
Under some conditions, it can be cancelled by clearTimeout() call unexpectedly, which cause the client stop polling.
The text was updated successfully, but these errors were encountered: