Failed to decode packet cookie_request
[x] The FAQ doesn't contain a resolution to my issue
Versions
- minecraft-protocol: 1.55.0
- server: vanilla/spigot/paper 1.21.4
- node: 22.14.0
Detailed description of a problem
I'm trying to set up a simple offline-mode server that (currently) only spawns the player in a void world. The following code works for other versions (tested for 1.8 with slight adaptations to the login packet, 1.18, 1.19 and 1.20 with the same code, different data versions). Attempting to run the same code with 1.21 results in the connection being lost and the following error being shown:
Internal Exception: io.netty.handler.codec.DecoderException: Failed to decode packet 'clientbound/minecraft:cookie_request'.
Current code
const mc = require("minecraft-protocol")
const mcData = require("minecraft-data")("1.21")
const server = mc.createServer({
host: "127.0.0.1",
port: 25565,
version: "1.21",
"online-mode": false,
})
server.on("login", (client) => {
const p = mcData.loginPacket
console.log(p)
client.write("login", {
...p,
})
client.write("position", {
x: 0,
y: 0,
z: 0,
yaw: 0,
pitch: 0,
})
})
Expected behavior
The client should spawn in an empty world at the coordinates 0/0/0 immediately upon joining the server.
anything on this? I don't mean to rush anyone or be rude, would just like to know if anyone has any ideas what's causing this / what I could investigate to fix it myself and / or submit a PR for this.
The error says you're sending packet cookie_request wrong
Can you share the part of your code sending this packet?
On Mon, Apr 21, 2025, 10:21 HumanDuck23 @.***> wrote:
anything on this? I don't mean to rush anyone or be rude, would just like to know if anyone has any ideas what's causing this / what I could investigate to fix it myself and / or submit a PR for this.
— Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/node-minecraft-protocol/issues/1389#issuecomment-2817448877, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437WRNVV6CPIANXRNSF322RBYJAVCNFSM6AAAAAB2MMAYL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMJXGQ2DQOBXG4 . You are receiving this because you are subscribed to this thread.Message ID: @.*** com> HumanDuck23 left a comment (PrismarineJS/node-minecraft-protocol#1389) https://github.com/PrismarineJS/node-minecraft-protocol/issues/1389#issuecomment-2817448877
anything on this? I don't mean to rush anyone or be rude, would just like to know if anyone has any ideas what's causing this / what I could investigate to fix it myself and / or submit a PR for this.
— Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/node-minecraft-protocol/issues/1389#issuecomment-2817448877, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437WRNVV6CPIANXRNSF322RBYJAVCNFSM6AAAAAB2MMAYL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMJXGQ2DQOBXG4 . You are receiving this because you are subscribed to this thread.Message ID: @.*** com>
I'm not sending the packet myself, my entire code is the code I provided in the beginning... Is it send automatically somewhere?
This also seems to happen with prismarine-proxy, with no extra code, there's an issue there too, I'd link it but I'm on my phone right now
https://github.com/search?q=repo%3APrismarineJS%2Fnode-minecraft-protocol%20cookie_request&type=code it is not sent by node-minecraft-protocol automatically
You can enable debug mode to understand better what you receive and send
This is interesting... I enabled debug mode and it never logs anything about a cookie_request packet, yet I'm still getting that error on my client. This is the full code I'm using right now:
const mc = require("minecraft-protocol")
const mcData = require("minecraft-data")("1.21.4")
const server = mc.createServer({
host: "127.0.0.1",
port: 25565,
version: "1.21.4",
"online-mode": false,
})
server.on("login", (client) => {
const p = mcData.loginPacket
client.write("login", {
...p,
})
client.write("position", {
x: 0,
y: 0,
z: 0,
yaw: 0,
pitch: 0,
})
})
And this is the error I'm seeing client-side:
And this is the entire log: https://pastebin.com/ixmWMsd4
It's never writing that packet, yet the error still shows up on the client, how is that possible?
it looks like the state isn't correct when I write my packets?
minecraft-protocol writing packet login.login +176ms
minecraft-protocol writing packet login.position +2ms
These are the only packets I myself write in the code and they should be play.login and play.position, why is this happening?
https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/examples/server_world/mc.js#L25 you need to listen to playerJoin not login event
Doing that doesn't work either, though now I just get a "Network Protocol Error" message.
This is the log for that: https://pastebin.com/BYEauP0z It seems that it never even writes the packets I write in the listener.
I adapted the code to work the way I intend for 1.8.9, and this is it:
const mc = require("minecraft-protocol")
const server = mc.createServer({
host: "127.0.0.1",
port: 25565,
version: "1.8.9",
"online-mode": false,
})
server.on("login", (client) => {
client.write("login", {
entityId: 0,
gameMode: 0,
dimension: 0,
difficulty: 2,
maxPlayers: 20,
levelType: "default",
reducedDebugInfo: false
})
client.write("position", {
x: 0,
y: 0,
z: 0,
yaw: 0,
pitch: 0,
})
})
I'm just trying to make this work with any version. Why does it work with login here, and why should I use playerJoin instead? Does the API change between MC versions? It also works with playerJoin though. Why is that the case in 1.8 but not other versions?
Yes the packet changes between versions, a lot.
If you want something easier I'd recommend https://github.com/PrismarineJS/flying-squid which is an higher level wrapper of node-minecraft-protocol server
Doing that doesn't work either
Doing what exactly?
Doing what exactly?
Sorry, using the playerJoin event doesn't work as I would like it to.
If I have this code now:
const mc = require("minecraft-protocol")
const server = mc.createServer({
host: "127.0.0.1",
port: 25565,
version: false,
"online-mode": false,
})
server.on("login", (client) => {
const mcData = require("minecraft-data")(client.version)
const p = mcData.loginPacket
client.write("login", {
...p,
})
client.write("position", {
x: 0,
y: 0,
z: 0,
yaw: 0,
pitch: 0,
})
})
This should work on many versions (not 1.8 because mcData.loginPacket doesn't exist, but that doesn't matter. This works on multiple versions (1.18, 1.19, 1.20) but fails for 1.21 with the error I initially had when creating this issue. Why does login work there? Using playerJoin instead works as well, for the versions I tested, yet once again, not for 1.21. Shouldn't this also work for 1.21?
login -> cookie_request error
playerJoin -> Network Protocol Error
login event is too early
For 1.21 you need other packets as well iirc
But generally if you want something that works across version that's what we built at flying-squid. You can read the code there if you want
https://github.com/PrismarineJS/flying-squid/blob/4241690254b081ace608050da34b11a2a22a50e7/src/lib/plugins/login.js#L20
Ah alright. The final goal really is to have a proxy that works for multiple versions of the game, but afaik prismarine-proxy requires you to specify a server and / or client version when creating it, so I was going to make my own version of that. I don't really need advanced server features besides it just working and being able to proxy packets back and forth.
@HumanDuck23 did you find any fix for it? I'm on 1.21.4, trying to do client.end("<reason>") in the playerJoin event and also got the same Network Protocol Error
@HumanDuck23 did you find any fix for it? I'm on 1.21.4, trying to do
client.end("<reason>")in theplayerJoinevent and also got the same Network Protocol Error
update: client.end("") worked, passing an empty string as the parameter. In minecraft it showed "Disconnected". The same error persists if I added characters with spaces like client.end("Server is still starting...")
update:
client.end("")worked, passing an empty string as the parameter. In minecraft it showed "Disconnected". The same error persists if I added characters with spaces likeclient.end("Server is still starting...")
I also get the same. If providing a reason other than blank, this error shows. In my use case, using the playerJoin event is too late because I just want the attempted login to trigger some logic in my backend before ending the session with the client. If my client is running NeoForge, the client fails before reaching the playerJoin event with "You are trying to connect to a server that is not running NeoForge, but you have mods that require it. A connection could not be established.".
The error occurs because there are unexpected characters in the client end reason. I am using Node 24.0.1, minecraft-protocol 1.57.0, and Minecraft 1.21.1. Here is my code that can reproduce the error:
import mc from "minecraft-protocol";
const server = mc.createServer({
version: false,
"online-mode": false,
});
server.on("login", (client) => {
client.end("You have been disconnected!");
// client.end("you_have_been_disconnected");
});
I get this message on the Minecraft client:
And the debug report produced by the Minecraft client when trying to connect:
---- Minecraft Network Protocol Error Report ----
// Wait, was the last bit one or zero?
Time: 2025-05-13 22:45:58
Description: Packet handling error
io.netty.handler.codec.DecoderException: Failed to decode packet 'clientbound/minecraft:cookie_request'
at yw.a(SourceFile:38)
at yw.decode(SourceFile:14)
at wd.decode(SourceFile:31)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:529)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.handler.flow.FlowControlHandler.dequeue(FlowControlHandler.java:202)
at io.netty.handler.flow.FlowControlHandler.channelRead(FlowControlHandler.java:164)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: aa: Non [a-z0-9/._-] character in path of location: minecraft:You have been disconnected!
at akr.f(SourceFile:285)
at akr.b(SourceFile:60)
at akr.a(SourceFile:89)
at akr.a(SourceFile:56)
at vw.q(SourceFile:586)
at abp.<init>(SourceFile:15)
at yx$6.decode(SourceFile:37)
at yx$9.a(SourceFile:91)
at yx$9.decode(SourceFile:87)
at yw.a(SourceFile:36)
... 39 more
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Thread: Netty Client IO #14
Stacktrace:
at wf.a(SourceFile:33)
-- Connection --
Details:
Protocol: configuration
Flow: CLIENTBOUND
Server type: OTHER
Server brand: ~~NULL~~
Stacktrace:
at wf.a(SourceFile:33)
at zj.a(SourceFile:62)
at fzc.a(SourceFile:136)
at fzc.a(SourceFile:127)
at vt.exceptionCaught(SourceFile:161)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:346)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:325)
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:317)
at io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(ChannelInboundHandlerAdapter.java:143)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:346)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:447)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.handler.flow.FlowControlHandler.dequeue(FlowControlHandler.java:202)
at io.netty.handler.flow.FlowControlHandler.channelRead(FlowControlHandler.java:164)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at java.base/java.lang.Thread.run(Thread.java:1583)
-- System Details --
Details:
Minecraft Version: 1.21.1
Minecraft Version ID: 1.21.1
Operating System: Windows 11 (amd64) version 10.0
Java Version: 21.0.3, Microsoft
Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Microsoft
Memory: 219299560 bytes (209 MiB) / 570425344 bytes (544 MiB) up to 2147483648 bytes (2048 MiB)
CPUs: 24
Processor Vendor: AuthenticAMD
Processor Name: AMD Ryzen 9 5900X 12-Core Processor
Identifier: AuthenticAMD Family 25 Model 33 Stepping 0
Microarchitecture: Zen 3
Frequency (GHz): 3.70
Number of physical packages: 1
Number of physical CPUs: 12
Number of logical CPUs: 24
Graphics card #0 name: NVIDIA GeForce RTX 3080 Ti
Graphics card #0 vendor: NVIDIA
Graphics card #0 VRAM (MiB): 12288.00
Graphics card #0 deviceId: VideoController1
Graphics card #0 versionInfo: 32.0.15.7283
Memory slot #0 capacity (MiB): 16384.00
Memory slot #0 clockSpeed (GHz): 3.60
Memory slot #0 type: DDR4
Memory slot #1 capacity (MiB): 16384.00
Memory slot #1 clockSpeed (GHz): 3.60
Memory slot #1 type: DDR4
Virtual memory max (MiB): 40884.97
Virtual memory used (MiB): 30696.55
Swap memory total (MiB): 8192.00
Swap memory used (MiB): 129.70
Space in storage for jna.tmpdir (MiB): available: 192065.52, total: 902552.00
Space in storage for org.lwjgl.system.SharedLibraryExtractPath (MiB): available: 192065.52, total: 902552.00
Space in storage for io.netty.native.workdir (MiB): available: 192065.52, total: 902552.00
Space in storage for java.io.tmpdir (MiB): available: 192065.52, total: 902552.00
Space in storage for workdir (MiB): available: 192065.52, total: 902552.00
JVM Flags: 9 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M
As you can see, my end reason contained some disallowed characters: Caused by: aa: Non [a-z0-9/._-] character in path of location: minecraft:You have been disconnected!.
If I try this on an older Minecraft client like 1.18.2, there is no error and I see the disconnection reason.
Now, going back to 1.21.1, if I change the message to only contain the correct characters like "you_have_been_disconnected", I lose the end reason entirely:
This end reason is quite useful to me. Has the Minecraft protocol changed such that it doesn't support this now?
Did replacing spaces with underscores resolve your issue?
@blacbrue Yes it did work in that the client doesn't see the ugly Internal Exception, and the login event fires. But, on 1.21.1, the client doesn't show the end reason I provided; it just says 'Disconnected'.
Ah i see, ig im just gonna have to settle with just "Disconnected", appreciate your detailed insight into this
Version: 1.21.4 Event: playerJoin Event not working: https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/src/client/play.js#L32
const server = mcp.createServer({
"online-mode": false,
version: "1.21.4",
port: 25565,
});
server.on("playerJoin", (client) => {
console.log("playerJoin");
});
read packet handshaking.set_protocol +0ms
read packet login.login_start +45ms
writing packet login.compress +1ms
writing packet login.success +4ms
read packet login.login_acknowledged +452ms
writing packet configuration.registry_data +37ms
writing packet configuration.registry_data +14ms
writing packet configuration.registry_data +2ms
writing packet configuration.registry_data +3ms
writing packet configuration.registry_data +3ms
writing packet configuration.registry_data +1ms
writing packet configuration.registry_data +9ms
writing packet configuration.registry_data +1ms
writing packet configuration.registry_data +7ms
writing packet configuration.registry_data +6ms
writing packet configuration.registry_data +5ms
writing packet configuration.registry_data +3ms
writing packet configuration.finish_configuration +2ms
read packet configuration.custom_payload +0ms
read packet configuration.settings +1ms
Should have been fixed with #1355, update your deps with npm update to make sure you have latest deps