Skip to content

Conversation

@derklaro
Copy link
Member

@derklaro derklaro commented Apr 1, 2025

Motivation

Currently, when a server unexpectedly closes the connection to the proxy, the player gets disconnected as CloudNet does not provide a fallback server. This is due to the fact that the ServerKickEvent is only called when the server sends a kick packet. In case the server goes down, BungeeCord tries to connect the player to the first priority (in our case a dummy lobby server as BungeeCord won't start without a priority) with the connection reason SERVER_DOWN_REDIRECT. We can catch this reason and provide a proper fallback in ServerConnectEvent.

Modification

Catch the SERVER_DOWN_REDIRECT reason in ServerConnectEvent and provide a proper fallback. If no fallback is available, disconnect the player with the new disconnection reason introduced in #1399.

Result

Players will be provided with a proper fallback in case of an unexpected connection close by the downstream service instead of being disconnected.

@derklaro derklaro added v: 4.X This pull should be included in the 4.0 release t: fix A pull request introducing a fix for a bug. in: module An issue/pull request releated to one of the internal modules labels Apr 1, 2025
@derklaro derklaro added this to the 4.0.0-RC12 milestone Apr 1, 2025
@derklaro derklaro requested a review from 0utplay April 1, 2025 09:22
@derklaro derklaro self-assigned this Apr 1, 2025
@0utplay 0utplay merged commit 7fdc624 into nightly Apr 1, 2025
7 checks passed
@0utplay 0utplay deleted the fix-fallback-on-server-crash branch April 1, 2025 19:07
GiantTreeLP pushed a commit to GiantTreeLP/CloudNet that referenced this pull request Jun 7, 2025
…#1602)

### Motivation
Currently, when a server unexpectedly closes the connection to the
proxy, the player gets disconnected as CloudNet does not provide a
fallback server. This is due to the fact that the ServerKickEvent is
only called when the server sends a kick packet. In case the server goes
down, BungeeCord tries to connect the player to the first priority (in
our case a dummy `lobby` server as BungeeCord won't start without a
priority) with the connection reason `SERVER_DOWN_REDIRECT`. We can
catch this reason and provide a proper fallback in `ServerConnectEvent`.

### Modification
Catch the `SERVER_DOWN_REDIRECT` reason in `ServerConnectEvent` and
provide a proper fallback. If no fallback is available, disconnect the
player with the new disconnection reason introduced in CloudNetService#1399.

### Result
Players will be provided with a proper fallback in case of an unexpected
connection close by the downstream service instead of being
disconnected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: module An issue/pull request releated to one of the internal modules t: fix A pull request introducing a fix for a bug. v: 4.X This pull should be included in the 4.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants