PrismarineJS / bedrock-protocol

Minecraft Bedrock protocol library, with authentication and encryption
https://prismarinejs.github.io/minecraft-data/?v=bedrock_1.17.10&d=protocol
MIT License
288 stars 68 forks source link

(Relay) Unable to join select realms or servers #474

Open JSbETms opened 5 months ago

JSbETms commented 5 months ago

When attempting to join any realm with relay the client is kicked with "Server sent broken packet" image The code I used is the same as the one supplied in API.md. This is not because I am banned on said realm(s) as the regular client works fine.

extremeheat commented 5 months ago

Only on Realms? Not on a vanilla server? Can you provide the debug logs (see README.md)? And make sure to set logging: true in the client options.

JSbETms commented 5 months ago

Both on realms and vanilla servers. Here is the console output with debug and logging enabled Console Output.

extremeheat commented 5 months ago

Ok, will look into it. Do you know if this started with 1.20.50 or does it happen on 1.20.40 also?

extremeheat commented 5 months ago

Can't reproduce, on client 1.20.51. Check your dependencies with npm update and your code.

image

JSbETms commented 5 months ago

After having a better look at it, it only seems to disconnect with specific realms/servers (Similar to what happened with #426). Here is the amended code I have used:

const { Relay } = require('bedrock-protocol')
const relay = new Relay({
  host:'0.0.0.0',
  port:19132,
  destination:{realms:{realmInvite:'code'}}
})
relay.listen()
relay.on('connect', player => {
  console.log('New connection', player.connection.address)
})
extremeheat commented 5 months ago

You're going to need to provide more specifics on how to reproduce (ie what servers) or there is no path to resolution here.

The log file you provided shows the server disconnecting you without sending any disconnect packet, just closing the connection. That could be anything, so can't extract any meaningful information from that.

JSbETms commented 5 months ago

Sorry for being vague. I'm not certain but I believe it may be related to scoreboards or enums.

extremeheat commented 5 months ago

Can you elaborate?

JSbETms commented 5 months ago

The client is only kicked when a scoreboard is present on the realm/server so I think it could be related to packets concerning scoreboards (Like update_soft_enum)

extremeheat commented 5 months ago

Can you show something to explain more on that? Where in the server<->client communications do you see things related to scoreboards? Your only log file shows you being disconnected before spawning.

JSbETms commented 5 months ago

Only on Realms? Not on a vanilla server? Can you provide the debug logs (see README.md)? And make sure to set logging: true in the client options.

Is there a way for logging to send the output directly to a file instead of the console? I would be able to give a more detailed log as my console would not fill up.

JSbETms commented 4 months ago

Apologies, here is a more detailed Log.

extremeheat commented 4 months ago

You'll need to provide some steps to reproduce otherwise nothing can be done here. The log file doesn't contain anything out of the ordinary, the server is just choosing to close the connection without sending a disconnect packet. That could be anything, bad network connection, server crashing/erroring, etc.

ATripple commented 4 months ago

image It's a crasher..

JSbETms commented 3 months ago

It's a crasher..

The client is kicked under certain conditions, also when players are not online, on a private server/realm.

Cdm2883 commented 3 months ago

I'm also bothered by this question.

So far I've found 2 servers that cause Relay to crash with "Server sent broken packet".

One of them crashes immediately after loading the resource pack before rendering the world.

The other one can enter the game's rendered world, but will crash at an unknown point shortly after.

The console output on crash is the same as this.

Both on realms and vanilla servers. Here is the console output with debug and logging enabled Console Output.

This console output seems to only tell that it crashed, not what it went through before it crashed.

It's also interesting to note that if you don't use relay and use bedrock.createClient() or new Client(), you won't have this error sent.

Can I give any additional information to help with this?

JSbETms commented 3 months ago

After experimenting around I think this issue may be related to custom/additional items, such as having education features enabled, experimental features (such as the “1.21” upcoming features toggle), or use of an external behaviour pack.

Cdm2883 commented 2 months ago

Sorry about my poor English <3

Okay, I seem to have found out what the problem is. It's that the crafting_data packet has an old definition somewhere, and the issue may have to be transferred to the minecraft-data.

I have a temporary solution until fixing the definition, I can try to make the crafting_data packet be forwarded to the client without processing. Here's how to do it:

Add a line of code to src/relay.js#L62 with the following line: if (name === 'crafting_data') return

If you want to make the changes before fixing it, but the package still retains the changes when it is updated, you can try the patch-package npm package.

(Hopefully bedrock-protocol will add a few configuration options so that packages that can't be parsed or custom excluded are forwarded directly to the client as-is, maybe I'll make a pr for that later?)

extremeheat commented 2 months ago

All packets should of course be parsed correctly, otherwise the purpose of the Relay to view/inspect/modify does not work. The behavior there should be the same as vanilla, for invalid packets we definitely want to throw where the client would not normally accept. If there is an issue with the crafting data packet then we should likely fix.

Re-enabling the debug option to check for encode/decode correctness seems like a good idea.