Skip to content
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

attach() doesn't trigger a poll #77

Open
alexstrat opened this issue Jan 27, 2012 · 2 comments
Open

attach() doesn't trigger a poll #77

alexstrat opened this issue Jan 27, 2012 · 2 comments

Comments

@alexstrat
Copy link

I noticed that, when attaching to a session, if there is no activity (send stanza) Strophe never polls.. and the session expires after a while whereas I'm attached..

When using #connect, Strophe polls at least every 60 seconds. When attached, should we not have the same behavior ?

I don't know if this should be fixed but I think I have the fix, which is not hard. Actually, the _onIdle process is not triggered because we are disconnected, it shall be restarted by hand : In #attach(), #_onIdle() shall be called at the end.

 attach: function (jid, sid, rid, callback, wait, hold, wind)
    {
       //...
       //Bla bala
       //...

        this._changeConnectStatus(Strophe.Status.ATTACHED, null);
        this._onIdle();
    },

I'll do a pull request if you find this relevant. Thanks.

@Marko-M
Copy link

Marko-M commented May 14, 2012

I had to place _onIdle() before this._changeConnectStatus because my attach() callback is being triggered there. If I place it at the end like you propose first stanza from my callback receives no response because there is no polling. Are we doing something wrong or is this an issue?

 attach: function (jid, sid, rid, callback, wait, hold, wind)
    {
       //...
       //Bla bala
       //...
        this._onIdle();
        this._changeConnectStatus(Strophe.Status.ATTACHED, null);
    },

@bodhi
Copy link

bodhi commented Feb 13, 2013

I've had the same problem. It seems it that attach() should call flush() before _changeConnectStatus(). This triggers the call to _onIdle(), and doesn't stomp on any existing timeouts configured. A workaround for it is to call flush() in the callback you pass to attach():

connection = new Strophe.Connection(host);
onAttach = function(status) {
  connection.flush();
  // do whatever else you need to do when connecting
};

connection.attach(jid, rid, sid, onAttach);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants