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

Auto-reconnect on refresh #2

Open
jmm312 opened this issue Feb 2, 2015 · 6 comments
Open

Auto-reconnect on refresh #2

jmm312 opened this issue Feb 2, 2015 · 6 comments

Comments

@jmm312
Copy link

jmm312 commented Feb 2, 2015

@orangecoloured I'm trying to modify the code to have it auto-reconnect to the server on browser refresh. I have modified index.js as shown in the image to remove the popup dialog. However, I am getting http://xx.xx.xx.xx/http-bind 404 (Invalid SID.) error. Any pointers?

screen shot 2015-02-02 at 6 12 10 am

@orangecoloured
Copy link
Owner

The problem is it's not an actual reconnect. It's an attachment to the existing connection.

It checks your JID, SID and RID. If i got everything right the SID is critical here. It has a small possible gap, like 1-5 for example. If you had a SID of 1 during the last request the server increases it by one and next time client must provide server with correct SID, in this case - 3.

I store the SID every request. And maybe on page refresh it can get not exactly the last value. So the next attachment it's going to send the old incorrect SID and get rejected. I tried increasing the SID on attach event, but no success. That's why I put the popup there and didn't make it the default behaviour.

I'll look into it later.

@jmm312
Copy link
Author

jmm312 commented Feb 2, 2015

Thank you for the quick response. I'll play around with the SID to see if I can get it to work.

@lgalant
Copy link

lgalant commented Jul 11, 2016

@jmm312 have you been able to resolve it?
@orangecoloured is it possible to avoid the need to reconnect by keeping the connection open while the app is in the background? I found that after some time the user gets disconnected from jabber

@orangecoloured
Copy link
Owner

orangecoloured commented Jul 11, 2016

@lgalant Do you mean in the background on the mobile?
I'm afraid Cordova apps can't run in the background and the disconnect happens because the app shuts down. That's why the attach method is the only good way to quickly reconnect on launching the app.

@lgalant
Copy link

lgalant commented Jul 11, 2016

@orangecoloured yes, I tweaked jabber to send messages as push notifications to the phone when the user is offline. When I click the notification it wakes the app up, but the user is offline.
Do you have any pointers on how to fix the BOSH attach?
I was thinking to store the password and do an actual reconnect, do you think that would work?

Thanks in advance for your help and awesome work on this app!

@orangecoloured
Copy link
Owner

@lgalant Well, the attach probably needs some debugging. It's in the XMPP docs, so I assume it should work. =)

But the logging in again is definitely going to work. I'm not sure if it's the best practice to store the password somewhere on the frontend side. But I don't see any other way to quickly log in after a disconnect not using the BOSH attach.

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