Paper/Spigot-Server-Patches/0245-Increase-time-allowed-for-a-keepalive-reply.patch
Shane Freeder 64ef6a6233
allow keepalive to wait longer for a client response
and also provide a bit more information in the server
logs so we can work out what is going on.
2017-10-16 15:37:17 +01:00

55 lines
2.5 KiB
Diff

From 584178f424f4af724835fd985b7c841bde8a3998 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 15 Oct 2017 00:29:07 +0100
Subject: [PATCH] Increase time allowed for a keepalive reply
This patch intends to bump up the time that a client has to reply to the
server back to 30 seconds as per pre 1.12.2, which allowed clients
more than enough time to reply potentially allowing them to be less
tempermental due to lag spikes on the network thread, e.g. that caused
by plugins that are interacting with netty.
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 26fbb30f9..5bb6d9fac 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -179,18 +179,25 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
}
this.minecraftServer.methodProfiler.a("keepAlive");
- long i = this.d();
-
- if (i - this.f >= 25000L) { // CraftBukkit
- if (this.g) {
- this.disconnect(new ChatMessage("disconnect.timeout", new Object[0]));
- } else {
- this.g = true;
- this.f = i;
- this.h = i;
- this.sendPacket(new PacketPlayOutKeepAlive(this.h));
+ // Paper Start - give clients a longer time to respond to pings as per pre 1.12.2 timings
+ // This should effectively place the keepalive handling back to "as it was" before 1.12.2
+ long currentTime = this.getCurrentMillis();
+ long elapsedTime = currentTime - this.getLastPing();
+ if (this.isPendingPing()) {
+ // We're pending a ping from the client
+ if (elapsedTime >= 30000L) { // 30 seconds for a ping reply
+ PlayerConnection.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getName()); // more info
+ this.disconnect(new ChatMessage("disconnect.timeout"));
+ }
+ } else {
+ if (elapsedTime >= 15000L) { // 15 seconds
+ this.setPendingPing(true);
+ this.setLastPing(currentTime);
+ this.setKeepAliveID(currentTime);
+ this.sendPacket(new PacketPlayOutKeepAlive(this.getKeepAliveID()));
}
}
+ // Paper end
this.minecraftServer.methodProfiler.b();
// CraftBukkit start
--
2.14.2