[BUG] Crash after joining server
Prerequisites
- [X] I made sure I am running the latest development build
- [X] I tried to look for similar issues before opening a new one
- [X] I have set
debugmessages=truein config to diagnose my issue - [X] I have redacted session tokens and passwords before attaching screenshots
Minecraft Version
1.20.1
Console Client Version
MinecraftClient-20240114-240-win-x64
Expected Behavior
Successfully Join Server
Actual Behavior
Crash after joining server.
Steps to Reproduce the bug
- Join Server
- Crash
Attach screenshot here (If applicable)
No response
Anythings that could help diagnosing the bug
[MCC] 已成功加入服务器。
输入 '/quit' 离开服务器。
> Unhandled exception. System.Collections.Generic.KeyNotFoundException: Packet ID of 0x4D4B doesn't exist!
at MinecraftClient.Protocol.Handlers.PacketPalettes.PacketTypePalette.GetIncommingTypeById(Int32 packetId)
at MinecraftClient.Protocol.Handlers.Protocol18Handler.HandlePacket(Int32 packetId, Queue`1 packetData)
at MinecraftClient.Protocol.Handlers.Protocol18Handler.Updater(Object o)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
Device
Laptop
Operating System
Windows
Server Address (If applicable)
No response
Happens only on specific servers, tried all supported versions.
Hi @RainC7 , Are you using a Vanilla server or a Forge server?
Edit: I tested with the Vanilla server and didn't reproduce the issue.
Hi @RainC7 , Are you using a Vanilla server or a Forge server?
Edit: I tested with the Vanilla server and didn't reproduce the issue.
PaperMC with Velocity
After testing, neither the chat machine nor the normal client will encounter problems.In MCC Client, the error is reported as above.
I think the Velocity may be causing this. Can this packet be blocked? :)
I used the latest version of PaperMC with Velocity and then joined the paper server as lobby and didn't reproduce the issue, maybe you need to specify the game version in the MinecraftClient.ini config file.
MinecraftVersion = "1.20.1"
Would like to give more details about the tests. For example:
- Exact Paper version and Velocity version (it would help more if you could include the relevant links)
- Paper startup command line and Velocity startup command line
- List of plugins installed on the server
compression-threshold=0
I asked the server administrator and got this answer.
This setting will cause MCC to be unable to connect. After adjusting this value, you can connect normally.
What problem is causing this and can it be fixed?
compression-threshold=0I asked the server administrator and got this answer. This setting will cause MCC to be unable to connect. After adjusting this value, you can connect normally. What problem is causing this and can it be fixed?
I think I know where the problem is.
/// <summary>
/// Read the next packet from the network
/// </summary>
/// <param name="packetId">will contain packet ID</param>
/// <param name="packetData">will contain raw packet Data</param>
internal Tuple<int, Queue<byte>> ReadNextPacket()
{
var size = dataTypes.ReadNextVarIntRAW(socketWrapper); //Packet size
Queue<byte> packetData = new(socketWrapper.ReadDataRAW(size)); //Packet contents
//Handle packet decompression
if (protocolVersion >= MC_1_8_Version
&& compression_treshold > 0)
{
var sizeUncompressed = dataTypes.ReadNextVarInt(packetData);
if (sizeUncompressed != 0) // != 0 means compressed, let's decompress
{
var toDecompress = packetData.ToArray();
var uncompressed = ZlibUtils.Decompress(toDecompress, sizeUncompressed);
packetData = new Queue<byte>(uncompressed);
}
}
var packetId = dataTypes.ReadNextVarInt(packetData); // Packet ID
if (handler.GetNetworkPacketCaptureEnabled())
handler.OnNetworkPacket(packetId, packetData.ToList(), currentState == CurrentState.Login, true);
return new(packetId, packetData);
}
There is a missing check that checks the length of the raw packet against the compression treshold. This could be the cause of the issue, I'll make a separate branch with the changes, and then you can test it.
From the Wiki.vg:
If the size of the buffer containing the packet data and ID (as a VarInt) is smaller than the threshold specified in the packet Set Compression. It will be sent as uncompressed. This is done by setting the data length as 0. (Comparable to sending a non-compressed format with an extra 0 between the length, and packet data).
If it's larger than the threshold, then it follows the regular compressed protocol format.
Compression can be disabled by sending the packet Set Compression with a negative Threshold, or not sending the Set Compression packet at all
So something like
var packetDataRaw = socketWrapper.ReadDataRAW(size);
Queue<byte> packetData = new(packetDataRaw); //Packet contents
//Handle packet decompression
if (protocolVersion >= MC_1_8_Version && compression_treshold > 0 && packetDataRaw.Length >= compression_treshold)
Should fix it.
compression-threshold=0I asked the server administrator and got this answer. This setting will cause MCC to be unable to connect. After adjusting this value, you can connect normally. What problem is causing this and can it be fixed?
Is that a setting on Velocity or on the Paper MC if you could ask the server owner? Also, can you share the IP so I can debug it?
compression-threshold=0I asked the server administrator and got this answer. This setting will cause MCC to be unable to connect. After adjusting this value, you can connect normally. What problem is causing this and can it be fixed?Is that a setting on Velocity or on the Paper MC if you could ask the server owner? Also, can you share the IP so I can debug it?
This setting is on Velocity. The server administrator has deprecated Velocity and updated it to Bungeecord. If necessary, you can adjust the Velocity settings to this, which will reproduce the problem. The server is private, sorry the IP cannot be shared.