tmail-flutter icon indicating copy to clipboard operation
tmail-flutter copied to clipboard

[WIP] TF-3157 Implement web socket push

Open tddang-linagora opened this issue 1 year ago • 17 comments

Issue

  • #3157

Demo

Screenshot 2024-09-23 at 16 54 50

tddang-linagora avatar Sep 23 '24 06:09 tddang-linagora

This PR has been deployed to https://linagora.github.io/tmail-flutter/3168.

github-actions[bot] avatar Sep 23 '24 06:09 github-actions[bot]

  • [ ] Verify web socket when token expired
  • [x] Verify web socket on background mode

dab246 avatar Sep 24 '24 02:09 dab246

Error connecting to web socket on lin-saas.dev

Screenshot 2024-10-09 at 15 40 06

tddang-linagora avatar Oct 09 '24 08:10 tddang-linagora

  • [x] WebSocket automatically closes after sending message
Screenshot 2024-10-09 at 16 33 37

dab246 avatar Oct 09 '24 09:10 dab246

Haven't seen it working yet. Please attach a demo video if you have tested it working properly.

dab246 avatar Oct 09 '24 09:10 dab246

WebSocket automatically closes after sending message

Currently web socket on lin-saas only lives in 1 minute. Not our problem

tddang-linagora avatar Oct 09 '24 09:10 tddang-linagora

Currently web socket on lin-saas only lives in 1 minute. Not our problem

Not that sure. Does the current poc set up some websocket PING ?

chibenwa avatar Oct 09 '24 09:10 chibenwa

Currently web socket on lin-saas only lives in 1 minute. Not our problem

Not that sure. Does the current poc set up some websocket PING ?

No ping. Does it state in the spec that we have to ping, and how often we need to ping?

tddang-linagora avatar Oct 09 '24 09:10 tddang-linagora

Haven't seen it working yet. Please attach a demo video if you have tested it working properly.

https://github.com/user-attachments/assets/5dc8f1ef-7d2e-4ea1-b730-de30edaa252b

tddang-linagora avatar Oct 09 '24 09:10 tddang-linagora

Does it state in the spec that we have to ping

Yes this is a standard websocket mechanism to keep connection open (otherwize Apisix closes it after 60 seconds)

https://api.flutter.dev/flutter/dart-io/WebSocket/pingInterval.html

Do it every 20 seconds.

chibenwa avatar Oct 09 '24 09:10 chibenwa

Apisix closes it after 60 seconds

That is the Back-end decision, not in https://www.rfc-editor.org/rfc/rfc8887

Do it every 20 seconds.

Will update

tddang-linagora avatar Oct 09 '24 09:10 tddang-linagora

That is the Back-end decision, not in https://www.rfc-editor.org/rfc/rfc8887

You are correct, but this document lacks proper guidance on exposing the timeouts (ideally in the session)

FYI something like that had been done on the regular Server sent event for JMAP: https://jmap.io/spec-core.html#event-source ping: A positive integer value representing a length of time in seconds, e.g., 300...

This was sadly omitted from the websocket spec so we will have to hard code it...

chibenwa avatar Oct 09 '24 09:10 chibenwa

Do it every 20 seconds.

@chibenwa Done

Screenshot 2024-10-10 at 09 17 49

tddang-linagora avatar Oct 10 '24 02:10 tddang-linagora

  • [x] WebSocket automatically closes after sending message
Screenshot 2024-10-09 at 16 33 37
  • [ ] Still get error when run web on debug mode with server lin-saas.dev

Screenshot 2024-10-10 at 15 04 17

dab246 avatar Oct 10 '24 08:10 dab246

Still get error when run web on debug mode with server lin-saas.dev

Browser?

tddang-linagora avatar Oct 11 '24 04:10 tddang-linagora

Still get error when run web on debug mode with server lin-saas.dev

Browser?

Chrome MacOS

dab246 avatar Oct 11 '24 04:10 dab246

Still get error when run web on debug mode with server lin-saas.dev

Browser?

Chrome MacOS

Backend just deployed the fix. Check again

tddang-linagora avatar Oct 11 '24 05:10 tddang-linagora

  • [ ] Firefox not work. Get error:
Screenshot 2024-10-29 at 11 19 15

dab246 avatar Oct 29 '24 04:10 dab246

  • [x] web_sockets_service.js removed when perform Ctrl + Shilf + R shortcut key

Screenshot 2024-10-29 at 12 00 29

dab246 avatar Oct 29 '24 05:10 dab246

web_sockets_service.js removed when perform Ctrl + Shilf + R shortcut key

https://blog.angular-university.io/service-workers/

If something is unclear while trying out Service Workers, trying to do a hard refresh (Ctrl+Shift+R) will not help in the learning process.

This is because if you hit hard-refresh, the whole Service Worker is going to be bypassed, and it won't control the page - This is the standard browser behavior which is unlikely to change.

Ctrl+Shift+R is meant to bypass all network caches, and because the Service Worker is often used for caching, it bypasses it too.

tddang-linagora avatar Oct 29 '24 08:10 tddang-linagora

  • [x] Sometime not work on chrome: Go to setting -> send email -> back to dashboard screen -> not update

https://github.com/user-attachments/assets/a2193e40-9695-4097-9fb5-f75da390de86

dab246 avatar Nov 05 '24 03:11 dab246