Skip to content

Mineflayer doesn't send configuration.settings packet at login, causing some servers to disconnect the user #3623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
PseudoResonance opened this issue Mar 29, 2025 · 16 comments
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@PseudoResonance
Copy link

PseudoResonance commented Mar 29, 2025

  • The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: 4.27.0
  • server: Hypixel 1.21.5/1.8.9
  • bun: 1.2.7 (also briefly tried node 22)

Detailed description of a problem

Mineflayer cannot join Hypixel on any version greater than 1.20.1 (versions 1.20.2-1.21.4). It disconnects with "socketClosed" after timing out.

What did you try yet?

Did you try any method from the API?
Did you try any example? Any error from those?

Your current code

Minimal repo: https://github.com/PseudoResonance/MineflayerBug/blob/main/src/bot.ts

Expected behavior

Mineflayer should join just like a vanilla 1.20.2-1.21.4 client.

Additional context

Debug Log
Creating bot
  minecraft-protocol [mc] entitlements {} +0ms
  minecraft-protocol [mc] profile {
  id: 'REDACTED',
  name: 'REDACTED',
  skins: [],
  capes: [],
  profileActions: {}
} +2ms
  minecraft-protocol writing packet handshaking.set_protocol +0ms
  minecraft-protocol {
  minecraft-protocol   protocolVersion: 764,
  minecraft-protocol   serverHost: 'mc.hypixel.net',
  minecraft-protocol   serverPort: 25565,
  minecraft-protocol   nextState: 2
  minecraft-protocol } +0ms
  minecraft-protocol writing packet login.login_start +31ms
  minecraft-protocol {
  minecraft-protocol   username: 'REDACTED',
  minecraft-protocol   signature: null,
  minecraft-protocol   playerUUID: 'REDACTED'
  minecraft-protocol } +0ms
  minecraft-protocol read packet login.encryption_begin +59ms
  minecraft-protocol {
  minecraft-protocol   "serverId": "344b3cd9861ae052",
  minecraft-protocol   "publicKey": {
  minecraft-protocol     "type": "Buffer",
  minecraft-protocol     "data": [
  minecraft-protocol       48,
  minecraft-protocol       129,
  minecraft-protocol       159,
  minecraft-protocol       48,
  minecraft-protocol       13,
  minecraft-protocol       ...,
  minecraft-protocol     ]
  minecraft-protocol   },
  minecraft-protocol   "verifyToken": {
  minecraft-protocol     "type": "Buffer",
  minecraft-protocol     "data": [
  minecraft-protocol       17,
  minecraft-protocol       221,
  minecraft-protocol       30,
  minecraft-protocol       197
  minecraft-protocol     ]
  minecraft-protocol   }
  minecraft-protocol } +1ms
  minecraft-protocol writing packet login.encryption_begin +165ms
  minecraft-protocol {
  minecraft-protocol   sharedSecret: <Buffer 44 20 f1 6d 95 cc 95 0f ea 65 77 ea 1c 57 93 d8 58 e9 85 ca fc 2d 51 4d 1a 7f 76 19 0a f3 fc 67 0d e3 9c bc 15 32 64 cc f1 39 08 2f 2a 44 59 72 1d 2c ... 78 more bytes>,
  minecraft-protocol   verifyToken: <Buffer 3e 1b e0 d3 92 c3 a5 f8 cc 63 b0 91 fc 5b bb bc 86 44 4a 75 ed d6 e7 5d f5 31 fe d2 42 e1 e4 4b ce 29 39 c7 2b 24 12 6e f8 3e e5 d4 77 59 a5 97 cf 1f ... 78 more bytes>
  minecraft-protocol } +0ms
  minecraft-protocol read packet login.compress +180ms
  minecraft-protocol {
  minecraft-protocol   "threshold": 256
  minecraft-protocol } +0ms
  minecraft-protocol read packet login.success +2ms
  minecraft-protocol {
  minecraft-protocol   "uuid": "REDACTED",
  minecraft-protocol   "username": "REDACTED",
  minecraft-protocol   "properties": []
  minecraft-protocol } +1ms
  minecraft-protocol writing packet login.login_acknowledged +0ms
  minecraft-protocol {} +0ms
Disconnected with reason socketClosed
error: false

I also saw #3435, but it seemed slightly different.

@PseudoResonance PseudoResonance added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Mar 29, 2025
@Sebastien-Moraz
Copy link

i have a same problem. i not found a solution. 😭

@PseudoResonance
Copy link
Author

Likely a duplicate of #3607

@PseudoResonance
Copy link
Author

PseudoResonance commented Apr 19, 2025

Looking at the debug log, why is the client information packet not sent immediately after login.login_acknowledged? A fabric client with no mods besides gadget will send the client information packet immediately afterwards.

The client just never sends configuration.settings here during the configuration phase.

I think it is likely that this discrepancy is the root cause.

@rom1504
Copy link
Member

rom1504 commented Apr 19, 2025

@PseudoResonance
Copy link
Author

That information packet is https://prismarinejs.github.io/minecraft-data/?d=protocol&v=1.20.5#configuration.toServer.types.packet_settings

I don't see anything on the Minecraft wiki's protocol documentation that seems to indicate whether it's strictly necessary or not, but I think it would make sense to send regardless, as that's what the vanilla client appears to do.

@rom1504
Copy link
Member

rom1504 commented Apr 19, 2025

Try it out indeed we don't send it

@rom1504
Copy link
Member

rom1504 commented Apr 19, 2025

Definitely vanilla doesn't require it

@PseudoResonance
Copy link
Author

PseudoResonance commented Apr 19, 2025

Definitely vanilla doesn't require it

I tested on Paper, Paper behind Waterfall and Paper behind Velocity, and it was able to connect to all 3, so unfortunately I wasn't able to reproduce it on a server I manage. I'm really not sure what kind of proxy/server setup that Hypixel and Wynncraft are using, but I'm guessing they adhere strictly to vanilla client behavior as somewhat of an anti-bot method.

I really should be asleep though, so if you happen to have the time to spare, I'd appreciate if you could try it out seeing as you probably know the codebase well, but if not, I'll try to take a look later today!

@rom1504
Copy link
Member

rom1504 commented Apr 19, 2025

https://github.com/PrismarineJS/node-minecraft-protocol/blob/9e116c3dd4682b17c4e2c80249a2447a093d9284/src/client/play.js#L53 here we can try adding something like client.write('packet_settings,{...the right fields here based on doc above})

@rom1504
Copy link
Member

rom1504 commented Apr 19, 2025

Although now I notice you're talking about hypixel, I guess they have a number of other captcha that would all need bypassing

@PseudoResonance
Copy link
Author

Although now I notice you're talking about hypixel, I guess they have a number of other captcha that would all need bypassing

Captcha? Other than that settings packet, I'm pretty certain that Mineflayer is pretty accurate to vanilla behavior.

I've been able to connect to Hypixel with Mineflayer for years now, on 1.12.2, 1.16.5, 1.18.2, 1.19.4 and 1.20/1.20.1. I had to keep raising the version obviously as Minecraft/Hypixel upgraded, but as of today, only 1.8 and 1.19+ are supported.

From my understanding, some of Hypixel's security comes from some kind of external packet monitoring algorithm. My guess is that all packets flowing through their proxy instances are also routed to some in-house app that uses a neural network to look for any anomalies and non-vanilla behavior. It's quite sophisticated, but shouldn't really be an issue for Mineflayer unless you're trying to be malicious.

@rom1504
Copy link
Member

rom1504 commented Apr 19, 2025

Captcha?

Yes few big servers try and detect non-human activity and kick the detected clients.
That is often called anticheat but that's a misnamer as they don't try to detect cheats but instead humans vs not
They detect a variety of stuff including order and timing of packets, gravity mismatch, etc
Would probably take some work to bypass all that

@PseudoResonance
Copy link
Author

Captcha?

Yes few big servers try and detect non-human activity and kick the detected clients. That is often called anticheat but that's a misnamer as they don't try to detect cheats but instead humans vs not They detect a variety of stuff including order and timing of packets, gravity mismatch, etc Would probably take some work to bypass all that

Yes, but as I said, Mineflayer is already quite good. I don't know about other servers, but there's really no extra work necessary to bypass anything on Hypixel in particular.

The only instance I have heard of is people who try to connect to Hypixel on Bedrock through Geyser. The packet timings I believe get them immediately kicked when they move. Mineflayer doesn't have this issue though, but regardless, if you try something malicious, you'll get caught through other detection systems.

@PseudoResonance
Copy link
Author

Yup, this is the issue. I can join Hypixel in 1.20.4 and 1.21.4 with that packet.

play.js

if (client.state === states.PLAY) {
  client.write('configuration_acknowledged', {})
}
client.state = states.CONFIGURATION
client.write('settings', {locale: "en_us", viewDistance: 10, chatFlags: 0, chatColors: true, skinParts: 127, mainHand: 1, enableTextFiltering: false, enableServerListing: true})
client.on('select_known_packs', () => {
  client.write('select_known_packs', { packs: [] })
})

@PseudoResonance
Copy link
Author

The Wynncraft issue @Sebastien-Moraz mentioned is not the same as this. Wynncraft sends a transfer packet shortly after login for load balancing purposes, but it seems Mineflayer doesn't yet handle those? From what I've heard, Hypixel will implement a similar load balancer sometime soon, so it will eventually affect Hypixel too.

@PseudoResonance PseudoResonance changed the title "socketClosed" while connecting to Hypixel in version 1.20.2 and above Mineflayer doesn't send configuration.settings packet at login, causing some servers to disconnect the user Apr 20, 2025
@Sebastien-Moraz
Copy link

The Wynncraft issue @Sebastien-Moraz mentioned is not the same as this. Wynncraft sends a transfer packet shortly after login for load balancing purposes, but it seems Mineflayer doesn't yet handle those? From what I've heard, Hypixel will implement a similar load balancer sometime soon, so it will eventually affect Hypixel too.

Is there a way around this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

3 participants