PaperMC / Velocity

The modern, next-generation Minecraft server proxy.
https://papermc.io/software/velocity
GNU General Public License v3.0
1.75k stars 608 forks source link

Player read timed out, when forwarding/redirecting to another server in `ServerPreConnectEvent` #778

Closed Osiris-Team closed 2 years ago

Osiris-Team commented 2 years ago

To reproduce try this:

        proxy.getEventManager().register(this, ServerPreConnectEvent.class, PostOrder.FIRST, event -> {
            try {
                event.setResult(ServerPreConnectEvent.ServerResult.allowed(newServer));
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        });

What happens: Player connects to the new server (can even be seen in the new servers' log) but velocity doesn't see it that way and gives Player read timed out after some time.

What should happen: Redirect the player to the new server, no read timed out.

Tested on Velocity 3.1.2-SNAPSHOT. Velocity log:

[22:15:24 INFO]: [initial connection] /ip:58401 is pinging the server with version 1.19
[22:15:25 INFO]: [connected player] DonnyDev (/ip:60076) has connected
[22:15:25 INFO] [triton]: [DEBUG] Saving language for ip...
[22:15:25 INFO] [triton]: [DEBUG] Saved language for ip!
[22:15:25 INFO] [velocityauth]: Blocked connect to 'Lobby' and forwarded DonnyDev to 'velocity_auth_limbo'. Player not logged in.
[22:15:25 INFO]: [server connection] DonnyDev -> velocity_auth_limbo has connected
[22:15:55 ERROR]: [connected player] DonnyDev (ip:60076): read timed out
[22:15:55 INFO]: [connected player] DonnyDev (ip:60076) has disconnected
[22:15:55 INFO]: [server connection] DonnyDev -> velocity_auth_limbo has disconnected

Limbo/new server log (also tested on regular spigot server, which results in the same outcome):

[22:15:14 Info] Loading Limbo Version 0.6.16-ALPHA on Minecraft 1.19
[22:15:14 Info] BungeeCord is enabled but so is Velocity Modern Forwarding or BungeeGuard, We will automatically disable BungeeCord forwarding because of this
[22:15:14 Info] No server-icon.png found
[22:15:14 Info] Loaded server.properties
[22:15:14 Info] If you are using bungeecord, consider turning that on in the settings!
[22:15:14 Info] Loading packet id mappings from mapping.json ...
[22:15:14 Info] Loaded all 47 packet id mappings!
[22:15:14 Info] Loading world minecraft:world with the schematic file spawn.schem ...
[22:15:14 Info] Schemetic file spawn.schem for world minecraft:world not found!
[22:15:14 Info] Creating default world...
[22:15:15 Info] Loaded world minecraft:world!
[22:15:15 Info] Limbo server listening on /0.0.0.0:30000
[22:15:25 Info] [/host-xxx.retail.xxx:54836|DonnyDev(7c87d6c0-9e28-4a11-8119-2531c31bc46d)] <-> Player had connected to the Limbo server!
[22:15:55 Info] [/host-xxx.retail.xxx:54836|DonnyDev] <-> Player had disconnected!
[22:16:02 Info] [/host-xxx.retail.xxx:54838|DonnyDev(7c87d6c0-9e28-4a11-8119-2531c31bc46d)] <-> Player had connected to the Limbo server!
[22:16:31 Info] [/host-xxx.retail.xxx:54838|DonnyDev] <-> Player had disconnected!
[22:19:36 Info] [/host-xxx.retail.xxx:54840|DonnyDev(7c87d6c0-9e28-4a11-8119-2531c31bc46d)] <-> Player had connected to the Limbo server!
[22:20:01 Info] [/host-xxx.retail.xxx:54840|DonnyDev] <-> Player had disconnected!
[22:30:18 Info] Stopping Server...
[22:30:18 Info] Server closed
Xernium commented 2 years ago

Cannot reproduce on a supported setup.

Osiris-Team commented 2 years ago

The problem was not with velocity, but with me doing stuff that should be done asynchronously in the ServerConnectedEvent.