Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClientKeepAlivePacket is processed incorrectly #2100

Open
GreenpixDev opened this issue Apr 20, 2024 · 0 comments · May be fixed by #2106
Open

ClientKeepAlivePacket is processed incorrectly #2100

GreenpixDev opened this issue Apr 20, 2024 · 0 comments · May be fixed by #2106

Comments

@GreenpixDev
Copy link

Description

The Minestom server isn't processing ClientKeepAlivePacket correctly.

This happens because all packets with CONFIGURATION and PLAY states are added to the player's packet queue and processed in the minestom tick thread (see method PacketProcessor#process(PlayerConnection, int, ByteBuffer)).

As a result, the player's latency is overestimated. For example, if you run a local minestom server, the latency will be about 50ms instead of the expected 0ms.

Report

The problem is relevant for the commit: e8e22a2

Steps to reproduce:

  1. Start the demo server locally
  2. Connect at localhost address
  3. Measure ping. To measure it you can add latency console output to the method KeepAliveListener#listener(ClientKeepAlivePacket, Player)
public static void listener(ClientKeepAlivePacket packet, Player player) {
    final long packetId = packet.id();
    if (packetId != player.getLastKeepAlive()) {
        player.kick(KICK_MESSAGE);
        return;
    }
    player.refreshAnswerKeepAlive(true);
    // Update latency
    final int latency = (int) (System.currentTimeMillis() - packetId);
    player.refreshLatency(latency);
+    System.out.println(latency)
}

Result

Expected result: latency close to 0ms
Actual result: latency close to 50ms

Potential solution

Potential solution: process the packet ClientKeepAlivePacket bypassing the player's packet queue (similar to packets with HANDSHAKE, STATUS and LOGIN states)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant