Websocket reconnecting infinitely

Summary
The websocket connections on clients are constantly reconnecting.

On desktop, I can see the following lines in the log:

websocket closed: 1001
websocket.js:211 websocket re-established connection
websocket_actions.jsx:222 Reconnecting WebSocket
https://mattermost.example.com/api/v4/posts/scheduled/team/REDACTED?includeDirectChannels=true 400 (Bad Request)
https://mattermost.marinero.hu/api/v4/custom_profile_attributes/fields 403 (Forbidden)

I’m using a Teams edition so the 400 and 403 errors are just because of licensing.

On mobile clients the Server is Not Reachable message can be seen all the time.

Steps to reproduce
I think this started since the last update 10.12

I’m using Cloudflare as DNS and proxy, tried disabling Cloudflare, but the issue remained.

Expected behavior
Websocket should work as before

Observed behavior
On server side, I can’t see any issue or relevant logs about this error.