Carpet TIS Addition

Carpet TIS Addition

530k Downloads

`/speedtest download` is incompatible with velocity >= 3.4.0-SNAPSHOT build 481

Closed this issue ยท 1 comments

commented

To reproduce

  1. Setup a server with carpet-tis-additon installed, setup a velocity server as the reversed proxy, join the server with carpet-tis-addition

  2. Run in Minecraft console

/carpet setDefault tiscmNetworkProtocol true
/carpet setDefault commandSpeedTest true
  1. Join the serveer, run in game:
/speedtest download 10
  1. The client gets disconnected
[03:36:24 INFO]: Booting up Velocity 3.4.0-SNAPSHOT (git-bd2bb632-b496)...
[03:36:24 INFO]: Loading localizations...
[03:36:24 INFO]: Connections will use NIO channels, Java compression, Java ciphers
[03:36:24 WARN]: Player info forwarding is disabled! All players will appear to be connecting from the proxy and will have offline-mode UUIDs.
[03:36:24 INFO]: Loading plugins...
[03:36:24 INFO]: Loaded 1 plugins
[03:36:24 INFO]: Listening on /[0:0:0:0:0:0:0:0]:25565
[03:36:24 INFO]: Done (0.75s)!
[03:36:29 INFO]: [connected player] Fallen_Breath (/127.0.0.1:62055) has connected
[03:36:29 INFO]: [server connection] Fallen_Breath -> lobby has connected
[03:36:32 INFO]: [connected player] Fallen_Breath (/127.0.0.1:62055) has disconnected: Your connection to lobby encountered a problem.

The exception is:

io.netty.handler.codec.CorruptedFrameException: Actual uncompressed size 16384 is greater than threshold 256
	at com.velocitypowered.proxy.protocol.util.NettyPreconditions.checkFrame(NettyPreconditions.java:83) ~[velocity-proxy-3.4.0-SNAPSHOT-all.jar:3.4.0-SNAPSHOT (git-b1e5cdcf)]
	at com.velocitypowered.proxy.protocol.netty.MinecraftCompressDecoder.decode(MinecraftCompressDecoder.java:56) ~[velocity-proxy-3.4.0-SNAPSHOT-all.jar:3.4.0-SNAPSHOT (git-b1e5cdcf)]
	at com.velocitypowered.proxy.protocol.netty.MinecraftCompressDecoder.decode(MinecraftCompressDecoder.java:34) ~[velocity-proxy-3.4.0-SNAPSHOT-all.jar:3.4.0-SNAPSHOT (git-b1e5cdcf)]
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:91) ~[velocity-proxy-3.4.0-SNAPSHOT-all.jar:3.4.0-SNAPSHOT (git-b1e5cdcf)]
...

Why

The issue is introduced by velocity's PR PaperMC/Velocity#1527 (PaperMC/Velocity@d9f1016), it adds a check on those uncompressed packet that throws an exception if the size of the uncompressed packet exceeded the compress threshold

/**
* Detect speed test payload to cancelling the compression, for less CPU usage
*/
@ModifyExpressionValue(
method = "encode(Lio/netty/channel/ChannelHandlerContext;Lio/netty/buffer/ByteBuf;Lio/netty/buffer/ByteBuf;)V",
at = @At(
value = "FIELD",
target = "Lnet/minecraft/network/PacketDeflater;compressionThreshold:I",
ordinal = 0
)
)
private int dontCompressSpeedTestPayloadPackets(int compressionThreshold, @Local(argsOnly = true, ordinal = 0) ByteBuf bufInput)
{
if (SpeedTestCompressionSkipper.isSpeedTestPayloadPacket(this, bufInput))
{
return Integer.MAX_VALUE;
}
return compressionThreshold;
}
}

Affects

Affected commands:

/speedtest download
/speedtest upload

More information

Carpet TIS Addition needs to send large packet in an uncompressed state, to
avoid packet compression becoming a bottleneck in network speed testing. So it cannot be fixed on the Carpet TIS Addition side

Issue on the velocity side: PaperMC/Velocity#1556

commented

Velocity now provides a method to disable the uncompressed packet size validation with java system property velocity.skip-uncompressed-packet-size-validation that fixes the incompatibility

Example fix (setting the system property in velocity launch argument):

java -Dvelocity.skip-uncompressed-packet-size-validation=true -jar velocity.jar

See commit PaperMC/Velocity@44bc15d