Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-32591: Reliable Websockets: Client side changes #7921

Merged
merged 3 commits into from
Apr 26, 2021
Merged

MM-32591: Reliable Websockets: Client side changes #7921

merged 3 commits into from
Apr 26, 2021

Conversation

agnivade
Copy link
Member

We send connection_id and sequence_number as part of the query params.

On receiving an event, we check if it's a hello packet, and if so,
we inspect the connection_id sent with it. If it's different to what
we have already, then we make the API calls and set sequence to 0.

And if the sequence number is different to what we expect, then
we just disconnect the connection, and expect the server to send
from where we left off.

NONE

https://mattermost.atlassian.net/browse/MM-32591

We send connection_id and sequence_number as part of the query params.

On receiving an event, we check if it's a hello packet, and if so,
we inspect the connection_id sent with it. If it's different to what
we have already, then we make the API calls and set sequence to 0.

And if the sequence number is different to what we expect, then
we just disconnect the connection, and expect the server to send
from where we left off.

```release-note
NONE
```

https://mattermost.atlassian.net/browse/MM-32591
const MAX_WEBSOCKET_FAILS = 7;
const MIN_WEBSOCKET_RETRY_TIME = 3000; // 3 sec
const MAX_WEBSOCKET_RETRY_TIME = 300000; // 5 mins

const reliableWebSockets = true;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be changed to actually take from the server config ServiceSettings.EnableReliableWebSockets

@agnivade agnivade removed the request for review from devinbinnie April 15, 2021 05:52
@agnivade
Copy link
Member Author

Hey @devinbinnie - I am handing this over to you. All that's needed is to actually take from the server config instead of a hardcoded boolean flag. There are 2 lint failures, but they might actually change when we change it to take from config.

Feel free to polish it however way you feel. But the logic is all there, and does not need to change.

@devinbinnie
Copy link
Member

@agnivade Alright I've setup the correct server config item to drive the use of reliable websockets. I also needed to make a change on the server branch wsfinal to add the item to the client config.

One question: currently if the server changes the config item and the websocket drops, reconnection won't work properly until the webapp is refreshed. Are we okay with that or should we be trying to find something more robust to make sure the switch over is seamless. I don't see the case coming up very often outside of a server admin turning on the feature and rebooting the server, disconnecting everyone.

@agnivade
Copy link
Member Author

Great question. Doesn't the webapp listen to config change events? If the admin changes the setting and reboots the server, the connection should try to reconnect and in the initialize function, getConfig(store.getState()); should return the new state?

@devinbinnie
Copy link
Member

Great question. Doesn't the webapp listen to config change events? If the admin changes the setting and reboots the server, the connection should try to reconnect and in the initialize function, getConfig(store.getState()); should return the new state?

Yes you're right, looks like it will call that again.
Funny enough, our reconnect logic really slows down after 8 attempts, going to every 3 minutes instead of 3 seconds (we multiply by the fail count twice), I wonder if that should change.

@agnivade
Copy link
Member Author

Yeah, I am aware of that. I don't want to touch that at this point. It should be a proper exponential backoff. Will look into it once the basic implementation gets in.

@agnivade agnivade marked this pull request as ready for review April 19, 2021 05:05
@agnivade agnivade added the Do Not Merge/Awaiting PR Awaiting another pull request before merging (e.g. server changes) label Apr 19, 2021
client/websocket_client.tsx Show resolved Hide resolved
client/websocket_client.tsx Show resolved Hide resolved
@hmhealey hmhealey removed the 2: Dev Review Requires review by a core commiter label Apr 22, 2021
@hmhealey
Copy link
Member

@agnivade Does this need QA review here or is that being done elsewhere?

@agnivade
Copy link
Member Author

Does this need QA review here or is that being done elsewhere?

Yeah Saturn is doing it on the server PR. He will take all the branches.

@agnivade
Copy link
Member Author

/update-branch

Copy link
Member

@saturninoabril saturninoabril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and passed.

@saturninoabril saturninoabril added the 4: Reviews Complete All reviewers have approved the pull request label Apr 26, 2021
@agnivade agnivade removed the Do Not Merge/Awaiting PR Awaiting another pull request before merging (e.g. server changes) label Apr 26, 2021
@agnivade agnivade merged commit 9a9f5e8 into master Apr 26, 2021
@agnivade agnivade deleted the wsfinal branch April 26, 2021 14:21
chetanyakan added a commit to brightscout-alpha/mattermost-webapp that referenced this pull request Apr 27, 2021
… MM-34128

* 'master' of github.com:mattermost/mattermost-webapp: (46 commits)
  Mm 27913 search channel tip (mattermost#6896)
  MM-35053 - cloud trial banner fixes (mattermost#7971)
  Fixing Zephyr keys for existing tests (mattermost#7977)
  Update NOTICE.txt (mattermost#7978)
  [MM-31934] Global policy form (mattermost#7816)
  MM-32591: Reliable Websockets: Client side changes (mattermost#7921)
  Translations update from Weblate (mattermost#7988)
  fix cloud onboarding tests (mattermost#7961)
  [MM-33428] remove check for Verify Signature (mattermost#7805)
  update compass icon font (mattermost#7965)
  [MM-35039] - Send trial ended email (mattermost#7967)
  Cypress/E2E: Fix tests related to email verification (mattermost#7960)
  Adding/fixing missing Zephyr keys and polishing tests (mattermost#7935)
  Mm 20425 migrate youtubevideo to typescript (mattermost#7786)
  MM-35074: short circuit slash command hooks (mattermost#7969)
  MM-34910 New messages toast should only count root posts (mattermost#7946)
  MM-31339: add e2e test for only one auto response per day (mattermost#7938)
  Cypress/E2E: Fix compliance export test (mattermost#7964)
  fix test related to channel switcher and bot display name (mattermost#7962)
  MM-34286: Adds missing authz checks. (mattermost#7891)
  ...
@amyblais amyblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels Apr 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation release-note-none
Projects
None yet
7 participants