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

Refresh page, or re-establish socket.io when connection is lost #84

Closed
lefnire opened this issue Jan 16, 2013 · 11 comments
Closed

Refresh page, or re-establish socket.io when connection is lost #84

lefnire opened this issue Jan 16, 2013 · 11 comments

Comments

@lefnire
Copy link
Contributor

lefnire commented Jan 16, 2013

Habit uses Socket.io to maintain persistence over real-time. If the server crashes and needs a restart, or if I push a fix - the session is broken between active clients and the server. The client flickers 'Disconnected' for a while, then when the server comes back online that message disappears - however, Socket hasn't made a proper re-connection, and any changes made between the time the server came down, and the time the user refreshes the page are completely lost.

The first thing to fix of course, is the server crashing for any reason. But that's a work in progress, and often out of my hands (I'm using the bleeding-edge Derby). Second thing to fix is to announce when I'm restarting the server (Twitter?). The biggest fix, however, will be to automatically refresh the page when the server connection has been re-detected. Possibly upgrading Socket.io, as well?

@lefnire
Copy link
Contributor Author

lefnire commented Jan 16, 2013

I'll make sure to tweet each deploy in the future, if I need to deploy before I can get an automated refresh in place. Follow me at @lefnire

@gemando
Copy link

gemando commented Jan 16, 2013

So (if I understand you correctly) I can't do anything at the moment about the "offline" messages which keep appearing apart from not to change/log anything because it won't save, and just to refresh the page to check if it's back online?

@lefnire
Copy link
Contributor Author

lefnire commented Jan 16, 2013

unfortunately, at present that is correct. I'm working on fixing this bug, and it's 99% a result of the huge traffic surge from today - so once that dies down we should have breathing room. If you can't wait to use the app, I'd say install on your machine at present (it's pretty easy actually), but I'm keep you posted on this thread as progress is made.

@gemando
Copy link

gemando commented Jan 16, 2013

Okay thank you. What difference will having it installed on my machine make? Will it just save my progress locally and then upload it to the main servers whenever they're online or does it run completely on my computer?

@lefnire
Copy link
Contributor Author

lefnire commented Jan 16, 2013

yeah, it would be completely on your computer. it would work smoothly, but you're right you'd miss out on social stuff & website integrations, so maybe just hang tight for now

@gemando
Copy link

gemando commented Jan 16, 2013

Will do :)

@ancientcampus
Copy link

Idea for a temporary patch:
When the server goes down, instead of saying "Disconnected from server, click here to reconnect" up top, make the whole screen go grey or something. Make it clear to the user that their clicks won't be saved.

@blueskymonster
Copy link

If you want to give users a few minutes of heads up before you deploy a new version, there's this little service: http://informuser.com/

@fedoranimus
Copy link

Could you store all the information being sent to the server in LocalStorage if there isn't a heartbeat from the server? That is, when the page detects the server being down (socket.io should send a 'disconnect' when it goes down), it will store whatever info you send to node.js in some form on LocalStorage. Then, have a heartbeat check happening on client side (just do a setTimeout() that asks for a simple message). If the heartbeat checks out, submit the stored data.

This might be totally off-base from what you want, but it's an idea. I don't know if Socket.io has this built in - been a few months since I've done work with it.

@lefnire
Copy link
Contributor Author

lefnire commented Feb 4, 2013

Derby uses memory store for when there's no connection. It stores
everything in the current browser session and pushes changes once the
connection is re-established. It would take quite some effort to change
that to LocalStorage, if someone's willing to write the plugin I'd be down,
but I'm not available for that. See Racer

On Mon, Feb 4, 2013 at 5:29 PM, Tim Turner notifications@github.com wrote:

Could you store all the information being sent to the server in
LocalStorage if there isn't a heartbeat from the server? That is, when the
page detects the server being down (socket.io should send a 'disconnect'
when it goes down), it will store whatever info you send to node.js in some
form on LocalStorage. Then, have a heartbeat check happening on client side
(just do a setTimeout() that asks for a simple message). If the heartbeat
checks out, submit the stored data.

This might be totally off-base from what you want, but it's an idea. I
don't know if Socket.io has this built in - been a few months since I've
done work with it.


Reply to this email directly or view it on GitHubhttps://github.com//issues/84#issuecomment-13103537.

@lefnire
Copy link
Contributor Author

lefnire commented Feb 7, 2013

this actually happens now, awesome. don't know if it was a recent racer release

@lefnire lefnire closed this as completed Feb 7, 2013
Alys referenced this issue in Alys/habitica Jul 14, 2014
Custom Day Start: change condition on when we run cron
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

5 participants