Provide a system property to set the keepalive limit

add a system property to allow people to tweak how long the server
will wait for a reply. There is a compromise here between lower and higher
values, lower values will mean that dead connections can be closed sooner,
whereas higher values will make this less sensitive to issues such as spikes
from networking or during connections flood of chunk packets on slower clients,
at the cost of dead connections being kept open for longer.
This commit is contained in:
Shane Freeder 2017-12-24 13:44:41 +00:00
parent 34731dd04e
commit c79d824fcd
No known key found for this signature in database
GPG Key ID: A3F61EA5A085289C
2 changed files with 23 additions and 8 deletions

View File

@ -1,7 +1,7 @@
From b9e5686a9c938851a0a3b41e34f0558890d6623a Mon Sep 17 00:00:00 2001 From 4857743f854572e63bd512528de0c968091a2ced Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com> From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 15 Oct 2017 00:29:07 +0100 Date: Sun, 15 Oct 2017 00:29:07 +0100
Subject: [PATCH] Increase time allowed for a keepalive reply Subject: [PATCH] revert serverside behavior of keepalives
This patch intends to bump up the time that a client has to reply to the 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 server back to 30 seconds as per pre 1.12.2, which allowed clients
@ -9,11 +9,26 @@ 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 tempermental due to lag spikes on the network thread, e.g. that caused
by plugins that are interacting with netty. by plugins that are interacting with netty.
We also add a system property to allow people to tweak how long the server
will wait for a reply. There is a compromise here between lower and higher
values, lower values will mean that dead connections can be closed sooner,
whereas higher values will make this less sensitive to issues such as spikes
from networking or during connections flood of chunk packets on slower clients,
at the cost of dead connections being kept open for longer.
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index a92bf8967..5a620f3fd 100644 index a92bf8967..d0ab87d0f 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java --- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/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 { @@ -100,6 +100,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
private int receivedMovePackets;
private int processedMovePackets;
private AutoRecipe H = new AutoRecipe();
+ private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) {
this.minecraftServer = minecraftserver;
@@ -179,18 +180,25 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
} }
this.minecraftServer.methodProfiler.a("keepAlive"); this.minecraftServer.methodProfiler.a("keepAlive");
@ -33,7 +48,7 @@ index a92bf8967..5a620f3fd 100644
+ long elapsedTime = currentTime - this.getLastPing(); + long elapsedTime = currentTime - this.getLastPing();
+ if (this.isPendingPing()) { + if (this.isPendingPing()) {
+ // We're pending a ping from the client + // We're pending a ping from the client
+ if (!this.processedDisconnect && elapsedTime >= 30000L) { // 30 seconds for a ping reply also, don't fire if already disconnected + if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected
+ PlayerConnection.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getName()); // more info + PlayerConnection.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getName()); // more info
+ this.disconnect(new ChatMessage("disconnect.timeout")); + this.disconnect(new ChatMessage("disconnect.timeout"));
+ } + }

View File

@ -1,4 +1,4 @@
From e7430c9e25f8ac7b7af64a674489b50a5438c194 Mon Sep 17 00:00:00 2001 From 53cac62ad4cf6b9c379fae5f0d51720ca5d4e886 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Sun, 26 Nov 2017 13:19:58 -0500 Date: Sun, 26 Nov 2017 13:19:58 -0500
Subject: [PATCH] AsyncTabCompleteEvent Subject: [PATCH] AsyncTabCompleteEvent
@ -14,10 +14,10 @@ completion, such as offline players.
Also adds isCommand and getLocation to the sync TabCompleteEvent Also adds isCommand and getLocation to the sync TabCompleteEvent
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 5a620f3fd..ead0994f8 100644 index d0ab87d0f..ca054afcf 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java --- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -2275,24 +2275,51 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { @@ -2276,24 +2276,51 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
// CraftBukkit end // CraftBukkit end
} }