[MM-62925] introduce websocket client-side ping #8633
+290
−20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a continuation of #8619. The PR was migrated to a branch on the upstream repository because E2E tests can't execute on branches from forked repositories.
Summary
This PR introduces new functionality on the client side to send PING messages over the websocket. If the server doesn't respond within
PING_INTERVAL
(currently 30 seconds), the connection is closed and re-created. This will allow us to find broken connections more quickly.Ticket Link
https://mattermost.atlassian.net/browse/MM-62925
This is related to a similar change in the webapp client: mattermost/mattermost#30293
Testing at the Application Layer
This change can be manually verified using a
mitmproxy
that intermittently drops websocket messages. This script will drop every otherPONG
message from the server, starting with the first:This proxy can be run with:
That will start delivering requests on
localhost:8080
to a local mattermost instance on the default port.Additionally to get around some CORS checks, the local instance needs to have its base URL set to
http://LOCAL_HOST_IP:8080
in the system console. The mobile app should connect tohttp://LOCAL_HOST_IP:8080
.With everything up and running, you'll see:
PING
, but the serverPONG
message is droppedPONG
was never received).PING
/PONG
interaction with the serverTesting at the Network Layer
We can also verify that the connection is re-established quickly after a failed attempt to send a PING message. This can happen if the packets are being rejected.
To test on a Mac:
localhost
at port8065
localhost:8065
)http://LOCAL_HOST_IP:8065
in the system console.http://LOCAL_HOST_IP:8065
.sudo pfctl -e && echo "block return proto tcp to port 8065" | sudo pfctl -f -
. This will block all tcp traffic to port 8065.sudo pfctl -d
. This will start allowing tcp traffic againChecklist
E2E iOS tests for PR
.Release Note