Feature/server outage screen#3199
Conversation
|
@MaartenD There are offline features in the app, so the lichess is down indicator should be less invasive in the UI. How do we make sure to distinguish between the server actually being down and the player simply being offline or experiencing network issues? |
|
@HaonRekcef that one i missed. I will do my research and let you know. |
|
@HaonRekcef is the Over the board game an offline feature? Are there more? |
|
@MaartenD there are multiple. You can disable the network on your device and see which buttons are interactable and not greyed out. |
|
@HaonRekcef what about this version? This is when in flightmode. Better.messaging.to.communicate.server.outage_ws_with_offline.mp4
Will upload a version when the websocket connection isn't working later today or tomorrow. I need to figure some things out first. |
|
**Behaviour during outage ** Below what is working so far. It's still work in progress but before i continue i would like to have somen answers according my approach (see Question below). Video when websocket isn't available Better.messaging.to.communicate.server.outage_ws_with_offline_wsgone.mp4
A new provider in lib/src/network/lichess_online.dart combines both checks: Currently applied to play_menu.dart, quick_game_matrix.dart and create_game_widget.dart. There are other places in the codebase that still use onlineStatusProvider directly, these would benefit from the same treatment. Question: to fully implement this feature i would like to know if you agree with my approach. Additionally, would you prefer lichessOnlineProvider to live in connectivity.dart alongside onlineStatusProvider rather than in a separate file? Tests added / updated
|
|
Hi @MaartenD thanks for the work on this! enum ConnectionStatus {
online,
networkDown,
serverDown,
} To answer your question: I am not the final authority, but I would say it doesn't matter much as long as the code is well written and works, personally I would tend towards putting it into the same file. |
|
Hi @HaonRekcef, Thanks for your reply and great suggestion according to the ConnectionStatus enum. I myself was also leaning towards putting everything in the same file. I will take that route. |
|
Reason for change New approach: ConnectionStatus enum Behaviour per status
Tests
Better.messaging.to.communicate.server.outage_ws_with_offline_II.mp4
Better.messaging.to.communicate.server.outage_ws_with_offline_wsgone_II.mp4To be clear: given the scope of this PR, I used Claude as an AI assistant during development (final implementation). |
|
@MaartenD I have not read the comments but only the PR description (which I hope you updated based on the last code). I have not read the code either, but based on the description I don't see how this can work. How do you distinguish a server outage from a network disconnection? Even if the socket is disconnected for more than 30s, that does not mean the lichess WS server is down. We certainly don't want to display a message indicating that the lichess server is down if that is not the case. And I don't see how you can know that by just monitoring the WS connection. I am pretty sure this feature cannot be implemented as is, or am I missing something? I invite you to reach out to the lichess server devs on discord to see how this is implemented in the website. |
Summary: Server outage detection via WebSocket
Below a description of what changed from previous version. See comment
What changed
The previous implementation in server_status.dart sent an HTTP HEAD request to lichessUri('/') every 30 seconds to check if the server was reachable. This was unnecessary overhead. The app already maintains a permanent WebSocket connection to lichess that continuously monitors server health through a ping/pong protocol.
New approach
The polling timer has been replaced by a listener on the existing WebSocket connection. The socket pool tracks connection health via averageLag, a value of Duration.zero means the socket is not connected.
When averageLag drops to zero a 30-second timer starts. If the connection is restored before the timer fires, it is cancelled and the server stays marked as online. If the timer fires, the server is marked as offline and the outage screen is shown. When the connection is restored, the server is immediately marked as online again.
Better.messaging.to.communicate.server.outage_ws.mp4
I tested it locally by stopping my lila_ws-1 docker container proces. When the outage screen was displayed i started the process again.
Fixes #1016