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 9ba62bc998
commit 67eb9725e2
2 changed files with 19 additions and 4 deletions

View file

@ -14,7 +14,7 @@ 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
@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { @@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {

View file

@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 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,10 +9,25 @@ 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
@@ -0,0 +0,0 @@ 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;
@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { @@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
} }
@ -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"));
+ } + }