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

Question: show connectivity, auto re-connect when offline #260

Open
proddy opened this issue Nov 3, 2021 · 13 comments
Open

Question: show connectivity, auto re-connect when offline #260

proddy opened this issue Nov 3, 2021 · 13 comments

Comments

@proddy
Copy link

proddy commented Nov 3, 2021

Hi Rick,

Some of the people using my EMS-ESP project get confused with the System/Restart feature where it says 'Device is restarting', the ESP reboots but the web page is not refreshed. It's a trvial thing, but the same happens with uploading firmware where you need to refresh the page when you think it's done.

So I was thinking what's the best way to check for connectivity to the web server and do retry's when it's offline. I would probably use WebSockets but before I embark on this I'm interested in how you would approach it?

@rjwats
Copy link
Owner

rjwats commented Nov 3, 2021 via email

@proddy
Copy link
Author

proddy commented Nov 3, 2021

ok, I'll give it a shot

@rjwats
Copy link
Owner

rjwats commented Dec 1, 2021

Was this still on your TODO list? Sounds like a good one and I have some ideas about how this might fit in to a UX refresh after the release of the new UI.

@proddy
Copy link
Author

proddy commented Dec 1, 2021

yes, it was. It's kind of an important one for my project and often requested. It'll also fix the annoying issue when after a firmware update the UI is not automatically refreshed (I'm pushing out updates weekly). I was going to base it off this code. But won't get to it soon as I'm still struggling getting the event source not to skip messages (and reading up on when to use Memo and Callback hooks)

@proddy
Copy link
Author

proddy commented Dec 15, 2021

@rjwats any thoughts on how to trigger a UI refresh after a successful firmware upload? Either via the heartbeat socket check or just hardcoded to trigger after the fileupload. This is an important one for me as I'm pushing out web UX changes every few weeks and my users (which I think could well be a few hundred now) always complain about not immediately seeing the latest UX changes. doh.

@rjwats
Copy link
Owner

rjwats commented Dec 15, 2021

I would show a spinner while I poll the "features" endpoint probably (because that endpoint is always present regardless of which features are enabled). I'd use a fairly short axios timeout, for a period of up to a couple of mins until the endpoint returns a 200 OK.

Then I would restart call document.location.reload() or force the document location to '/' on success to force the reload :)

Happy to knock together a PoC :) - i'm off till 2022!

@proddy
Copy link
Author

proddy commented Dec 15, 2021 via email

@rjwats
Copy link
Owner

rjwats commented Dec 16, 2021

@proddy
Copy link
Author

proddy commented Dec 16, 2021

Awesome! very fancy. So how long did that take you? I like the redirect route at the end. Also while we're (you are) at it is there way to verify the firmware with a CRC check?

@rjwats
Copy link
Owner

rjwats commented Dec 16, 2021

The verification check is an intresting one isn't it. Possibly generating an sha512 signature for the artefact and verifying that would be the way to go. The signature could be optional, and sent as a header on the file upload, and verified if supplied.

Should be as simple as calling md_update for each segment of the payload, and at then verifying it at the end before calling Update.end(true):

image

@rjwats
Copy link
Owner

rjwats commented Dec 16, 2021

Oh, and it took about an hour, just really needed to write a polling component 👍

@proddy
Copy link
Author

proddy commented Dec 19, 2021

I've been using the firmware upload monitor a lot and can say it works flawlessly, a good 1 hour spent!

@rjwats
Copy link
Owner

rjwats commented Dec 19, 2021 via email

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

2 participants