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

Provide push message support for Management UI/implement SSE #17

Open
UsualSpec opened this issue Jul 29, 2024 · 0 comments
Open

Provide push message support for Management UI/implement SSE #17

UsualSpec opened this issue Jul 29, 2024 · 0 comments

Comments

@UsualSpec
Copy link
Collaborator

UsualSpec commented Jul 29, 2024

During development, I was planning to allow the server to push messages like a successful measurement start, stop, status messages,... to the management UI and then to connected web browsers.
The cli.py script already supports this.

Data transmission would happen via server side events using https://flask-sse.readthedocs.io/en/latest/quickstart.html or https://maxhalford.github.io/blog/flask-sse-no-deps/ then the web browser would display a Bootstrap toast if a new message is incoming. The benefit is that a user would directly get messaged if a device changes status.
Unfortunately, during this time I did not know about monkey patching, meaning the server would hang as soon as one web browser tries to retrieve new messages from the (no longer implemented) getStatusMessages endpoint. Now this issue is fixed, and server side events could be implemented.

def getMessages(self, request, context):
shows the gRPC method used to retrieve messages from the server.

There even was an implementation attempt I reverted (check git history around Jun 04,2024 in the private repo if you have access).

In general, only having access to the messages sounds like not being that important.

However, allowing SSE in the Management UI is a worthy change and would potentially allow the project to benefit significantly from more interactivity since the server can now directly forward commands to end users:

  • Status updates on the main page could be updated automatically without needing to resort on polling (alternative implementation). This gives an up to date view of the current measurement status
  • Errors could be passed from the Autopower device to the server and then via the Management UI directly to the web browser of the connected user
  • The server could notify send a real "measurement started/stopped successfully" message to the web browser clients.
  • Even if stopping a measurement due to long lasting data upload takes > 30s (the timeout after which the request to a client is seen as unsuccessful) the Management UI would not just show a timeout error. It would now be able to notify the user later that the measurement did indeed stop successfully despite the timeout.

Implementation may have some hurdles, is not per se trivial but doable.

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

1 participant