diff --git a/build.gradle b/build.gradle index 7f2d40ebc..ebb5643c6 100644 --- a/build.gradle +++ b/build.gradle @@ -106,10 +106,10 @@ dependencies { testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.6.2') // Netty - api 'io.netty:netty-handler:4.1.58.Final' - api 'io.netty:netty-codec:4.1.58.Final' - api 'io.netty:netty-transport-native-epoll:4.1.58.Final:linux-x86_64' - api 'io.netty:netty-transport-native-kqueue:4.1.58.Final:osx-x86_64' + api 'io.netty:netty-handler:4.1.59.Final' + api 'io.netty:netty-codec:4.1.59.Final' + api 'io.netty:netty-transport-native-epoll:4.1.59.Final:linux-x86_64' + api 'io.netty:netty-transport-native-kqueue:4.1.59.Final:osx-x86_64' api 'io.netty.incubator:netty-incubator-transport-native-io_uring:0.0.3.Final:linux-x86_64' // https://mvnrepository.com/artifact/org.apache.commons/commons-text diff --git a/src/main/java/net/minestom/server/network/netty/NettyServer.java b/src/main/java/net/minestom/server/network/netty/NettyServer.java index fab6d580c..70236cc73 100644 --- a/src/main/java/net/minestom/server/network/netty/NettyServer.java +++ b/src/main/java/net/minestom/server/network/netty/NettyServer.java @@ -36,6 +36,8 @@ import java.util.concurrent.ScheduledExecutorService; public final class NettyServer { public static final Logger LOGGER = LoggerFactory.getLogger(NettyServer.class); + private static final WriteBufferWaterMark SERVER_WRITE_MARK = new WriteBufferWaterMark(1 << 20, + 1 << 21); private static final long DEFAULT_COMPRESSED_CHANNEL_WRITE_LIMIT = 600_000L; private static final long DEFAULT_COMPRESSED_CHANNEL_READ_LIMIT = 100_000L; @@ -154,6 +156,7 @@ public final class NettyServer { bootstrap = new ServerBootstrap() .group(boss, worker) + .childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, SERVER_WRITE_MARK) .channel(channel); diff --git a/src/main/java/net/minestom/server/network/netty/channel/ClientChannel.java b/src/main/java/net/minestom/server/network/netty/channel/ClientChannel.java index 519c34a95..aa14b7035 100644 --- a/src/main/java/net/minestom/server/network/netty/channel/ClientChannel.java +++ b/src/main/java/net/minestom/server/network/netty/channel/ClientChannel.java @@ -72,8 +72,11 @@ public class ClientChannel extends SimpleChannelInboundHandler { @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { + if (!ctx.channel().isActive()) { + return; + } + if (MinecraftServer.shouldProcessNettyErrors()) { - LOGGER.info(cause.getMessage()); MinecraftServer.getExceptionManager().handleException(cause); } ctx.close(); diff --git a/src/main/java/net/minestom/server/network/player/NettyPlayerConnection.java b/src/main/java/net/minestom/server/network/player/NettyPlayerConnection.java index edcb76c73..6ef65178c 100644 --- a/src/main/java/net/minestom/server/network/player/NettyPlayerConnection.java +++ b/src/main/java/net/minestom/server/network/player/NettyPlayerConnection.java @@ -112,7 +112,7 @@ public class NettyPlayerConnection extends PlayerConnection { */ @Override public void sendPacket(@NotNull ServerPacket serverPacket) { - if (!isOnline()) + if (!channel.isActive()) return; if (shouldSendPacket(serverPacket)) { @@ -152,7 +152,7 @@ public class NettyPlayerConnection extends PlayerConnection { if (MinecraftServer.shouldProcessNettyErrors()) { return channelFuture.addListener(future -> { - if (!future.isSuccess()) { + if (!future.isSuccess() && channel.isActive()) { MinecraftServer.getExceptionManager().handleException(future.cause()); } }); @@ -167,7 +167,7 @@ public class NettyPlayerConnection extends PlayerConnection { if (MinecraftServer.shouldProcessNettyErrors()) { return channelFuture.addListener(future -> { - if (!future.isSuccess()) { + if (!future.isSuccess() && channel.isActive()) { MinecraftServer.getExceptionManager().handleException(future.cause()); } });