bedrock-protocol
bedrock-protocol copied to clipboard
1.19.10 Chat is not being read
I am using the example scripts to listen to chat and chat is not being listened to. This was working fine on 1.19.1 and now is not working on 1.19.10.
const bedrock = require('bedrock-protocol')
const client = bedrock.createClient({ // optional
realms: {
realmInvite: "https://realms.gg/I4Pm46UEw6I"
}, // optional, default 19132
username: 'Wilco Realm Bot', // the username you want to join as, optional if online mode
})
client.on('text', (packet) => { // Listen for chat messages and echo them back.
if (packet.source_name != client.username) {
client.queue('text', {
type: 'chat', needs_translation: false, source_name: client.username, xuid: '', platform_chat_id: '',
message: `${packet.source_name} said: ${packet.message} on ${new Date().toLocaleString()}`
})
}
})
Why doesn't it work? Nothing printed out?
Can you add process.env.DEBUG = 'minecraft-protocol'
to the top of your script & rerun and provide the output? https://gist.github.com/
Thanks
@extremeheat Having the same issue here. Using 3.15.0 and minecraft-data 3.9.0, 3.9.1.
The callback in client.on('text', (packet) => {})
is not being called, and there is no debug output after the initial connection / handshake.
https://gist.github.com/nagytech/e4fa801f26da861b4eee08b66e6d554b
I can, however, send chat to the server just fine.
client.queue('text', {
type: 'chat', needs_translation: false, source_name: client.username, xuid: '', platform_chat_id: '',
message: `test`
})
Based on the log, the connection is failing and client is not allowed to spawn (you get no chunk data and all).
I tried on a vanilla 1.19.10 server and it works fine -
minecraft-protocol C <- Q <- text {
type: 'chat',
needs_translation: false,
...
Have you tried a different server ?
Haven’t tried a different server yet. This is a realms server BTW, not sure if that matters or not.
On Mon, 25 Jul 2022 at 16:54, extremeheat @.***> wrote:
Based on the log, the connection is failing and client is not allowed to spawn (you get no chunk data and all).
I tried on a vanilla 1.19.10 server and it works fine -
minecraft-protocol C <- Q <- text { type: 'chat', needs_translation: false, ...
Have you tried a different server ?
— Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/bedrock-protocol/issues/239#issuecomment-1193653526, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBFOUNLHAGO5GGRZBK3MA3VVY22LANCNFSM54OIGELQ . You are receiving this because you commented.Message ID: @.***>
Possibly if OP and you have same issues. Have you tried connecting to the server with a Relay proxy? There should be some doc on how to set this up.
If you are able to connect, please post another log file with the DEBUG flag set at top of your code like before.
Relay Code
const { Relay } = require('bedrock-protocol')
process.env.DEBUG = "bedrock-protocol"
function createRelay () {
console.log('Creating relay')
/* Example to create a non-transparent proxy (or 'Relay') connection to destination server */
const relay = new Relay({
/* host and port for clients to listen to */
host: '0.0.0.0',
port: 19130,
offline: false,
/* Where to send upstream packets to */
destination: {
realms: {
pickRealm: (realms) => realms[0] // I only have one realm, this is fine.
},
offline: false
}
})
relay.conLog = console.debug
relay.listen()
relay.on('connect', player => {
// Server is sending a message to the client.
player.on('clientbound', ({ name, params }) => {
console.log(params)
})
player.on('serverbound', ({ name, params }) => {
console.log(params)
})
})
}
createRelay()
Relay output
Creating relay
Listening on 0.0.0.0 19130 1.19.10
New connection from 127.0.0.1/43585
Connecting to 20.5.103.67 30421
Connected to upstream server
{
must_accept: false,
has_scripts: false,
force_server_packs: false,
behaviour_packs: [],
texture_packs: []
}
{ compression_threshold: 256 }
{ response_status: 'completed', resourcepackids: [] }
{ enabled: false }
{ request_time: 1658788267364n, response_time: 0n }
{
type: 'chat',
needs_translation: false,
source_name: 'xxxx',
message: 'test',
parameters: undefined,
xuid: '',
platform_chat_id: ''
}
{ chunk_radius: 10 }
{
type: 'chat',
needs_translation: false,
source_name: 'xxxx',
message: 'test',
parameters: undefined,
xuid: '',
platform_chat_id: ''
}
{
type: 'chat',
needs_translation: false,
source_name: 'xxxx',
message: 'test',
parameters: undefined,
xuid: '',
platform_chat_id: ''
}
Client Code
process.env.DEBUG = 'minecraft-protocol'
const bedrock = require('bedrock-protocol');
const client = bedrock.createClient({
// realms: {
// pickRealm: (r) => r[0]
// }
host: "127.0.0.1",
port: 19130
});
setInterval(() => {
client.queue('text', {
type: 'chat', needs_translation: false, source_name: client.username, xuid: '', platform_chat_id: '',
message: `test`
})
}, 5000);
client.on('text', (packet) => { // Listen for chat messages
console.log(`${JSON.stringify(packet)}`)
})
Client output
minecraft-protocol chains [
'xxxx',
'xxxx'
] +0ms
minecraft-protocol got xbox profile {
nbf: xxxx,
extraData: {
XUID: 'xxxx',
identity: 'xxxx',
displayName: 'xxxx',
titleId: 'xxxx'
},
randomNonce: xxxx,
iss: 'Mojang',
exp: xxxx,
iat: xxxx,
identityPublicKey: 'xxxx'
} +1ms
minecraft-protocol [client] connecting to 127.0.0.1 19130 {
name: 'xxxx',
uuid: 'xxxx',
xuid: 'xxxx'
} RakNativeClient {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
connected: false,
onConnected: [Function (anonymous)],
onCloseConnection: [Function (anonymous)],
onEncapsulated: [Function (anonymous)],
raknet: Client {
_events: [Object: null prototype] {
encapsulated: [Function (anonymous)],
connect: [Function (anonymous)],
disconnect: [Function (anonymous)]
},
_eventsCount: 3,
_maxListeners: undefined,
client: RakClient {},
ping: [Function (anonymous)],
connect: [Function (anonymous)],
close: [Function (anonymous)],
[Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false
} +0ms
minecraft-protocol * new status 1 +0ms
minecraft-protocol Auth chain [
'xxxx',
'xxxx',
'xxxx'
] +50ms
minecraft-protocol C <- login {
protocol_version: 534,
tokens: {
identity: '{"chain":["xxxx"]}',
client: 'xxxx'
}
} +1ms
minecraft-protocol while sending to RakNativeClient {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
connected: true,
onConnected: [Function (anonymous)],
onCloseConnection: [Function (anonymous)],
onEncapsulated: [Function: onEncapsulated],
raknet: Client {
_events: [Object: null prototype] {
encapsulated: [Function (anonymous)],
connect: [Function (anonymous)],
disconnect: [Function (anonymous)]
},
_eventsCount: 3,
_maxListeners: undefined,
client: RakClient {},
ping: [Function (anonymous)],
connect: [Function (anonymous)],
close: [Function (anonymous)],
[Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false
} Error: Failed to send: -5
at Client.send (/home/redacted/source/client/node_modules/raknet-native/lib/RakNet.js:57:13)
at RakNativeClient.sendReliable (/home/redacted/source/client/node_modules/bedrock-protocol/src/rak.js:76:24)
at Client.sendMCPE (/home/redacted/source/client/node_modules/bedrock-protocol/src/connection.js:139:23)
at Client.sendDecryptedBatch (/home/redacted/source/client/node_modules/bedrock-protocol/src/connection.js:128:10)
at Client.write (/home/redacted/source/client/node_modules/bedrock-protocol/src/connection.js:70:12)
at Client.sendLogin (/home/redacted/source/client/node_modules/bedrock-protocol/src/client.js:128:10)
at RakNativeClient.connection.onConnected (/home/redacted/source/client/node_modules/bedrock-protocol/src/client.js:102:46)
at Client.<anonymous> (/home/redacted/source/client/node_modules/bedrock-protocol/src/rak.js:42:12)
at Client.emit (node:events:527:28)
at /home/redacted/source/client/node_modules/raknet-native/lib/RakNet.js:35:20 +16ms
minecraft-protocol Client closed! +21ms
minecraft-protocol * new status 0 +14ms
minecraft-protocol C <- Q <- text {
type: 'chat',
needs_translation: false,
source_name: 'xxxx',
xuid: '',
platform_chat_id: '',
message: 'test'
} +4s
minecraft-protocol C <- Q <- text {
type: 'chat',
needs_translation: false,
source_name: 'xxxx',
xuid: '',
platform_chat_id: '',
message: 'test'
} +5s
You wrote the debug line wrong. It's minecraft-protocol case sensitive and must go all the way at the top of your code which is before any require() statements. This sets an environment variable for the Node.JS environment, as explained in our README.
https://github.com/PrismarineJS/bedrock-protocol/blob/370ca96f2e7e2adcf5c42672acc129b5d7cc68ea/src/client.js#L124 this seems wrong, it shouldn't be wrapped in an object
@rob9315
https://github.com/PrismarineJS/bedrock-protocol/blob/370ca96f2e7e2adcf5c42672acc129b5d7cc68ea/src/client.js#L124
this seems wrong, it shouldn't be wrapped in an object
This is an unrelated issue, in JS { chain }
without colons equals { chain: chain }
no i know that, the problem is that the packets description (for 1.19.10) says that it's an array:
Removing {}
breaks the authentication. On a related note, when connected to a Realm on my mobile and laptop chat isn't sent to either clients not even involving bedrock-protocol
Yeah, client joining is pretty well tested on CI. The issue here seems to be possibly wrong login sequence (missing a packet to send) so Realms is not accepting the client spawn request or something wrt authentication.
My bedrock-protocol client can receive text however only from certain accounts.
Using /msg
will send the chat to the bot irrespective of account used
Let's keep this issue focused on the matter @MrWilco and @nagytech have. If there are orthogonal problems not directly related please open new issues/discussion so things are easier to track.
Are there any suggestions on how I can compare the difference in between the prismarine client and the official client? Wireshark perhaps? Or any tool that you already have as a part of your dev process?
On Tue, 26 Jul 2022 at 10:15, extremeheat @.***> wrote:
Let's keep this issue focused on the matter @MrWilco https://github.com/MrWilco and @nagytech https://github.com/nagytech have. If there are orthogonal problems not directly related please open new issues/discussion so things are easier to track.
— Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/bedrock-protocol/issues/239#issuecomment-1194805064, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBFOUNS5QYTNAJEQSQD6S3VV4U3TANCNFSM54OIGELQ . You are receiving this because you were mentioned.Message ID: @.***>
@nagytech
As stated above , please correct this:
You wrote the debug line wrong. It's minecraft-protocol case sensitive and must go all the way at the top of your code which is before any require() statements. This sets an environment variable for the Node.JS environment, as explained in our README.
And provide a log with a vanilla client connected to the Relay which is connected to the backend server. It will make it easier to understand the login procedure and anything incorrect with how bedrock-protocol's client is initializing the connection.
Vanilla client -> Relay -> Realms? Sorry, I can't do that.
Might be easier for someone who knows this system to simply run the code and find the issue themselves.
Good luck!
Hi @nagytech - I've corrected the code that would be great if you could run. I don't have a Realms subscription myself, so just trying to help out those that do :)
process.env.DEBUG = "minecraft-protocol"
const { Relay } = require('bedrock-protocol')
function createRelay () {
console.log('Creating relay')
/* Example to create a non-transparent proxy (or 'Relay') connection to destination server */
const relay = new Relay({
/* host and port for clients to listen to */
host: '0.0.0.0',
port: 19130,
logging: true,
offline: false,
/* Where to send upstream packets to */
destination: {
realms: {
pickRealm: (realms) => realms[0] // I only have one realm, this is fine.
},
offline: false
}
})
relay.conLog = console.debug
relay.listen()
relay.on('connect', player => {
// Server is sending a message to the client.
player.on('clientbound', ({ name, params }) => {
console.log(params)
})
player.on('serverbound', ({ name, params }) => {
console.log(params)
})
})
}
createRelay()
Or if anyone is having similar problems, please run code above which makes a proxy server to connect to a Realm. You can connect to it and it should log many things to the console, drop that over to https://gist.github.com/ and post a link.
@extremeheat What I was debugging is related to this issue, I don't believe the errors encountered here are to do with bedrock-protocol but more so to do with an issue with Realms itself. See REALMS-9150, REALMS-9191 & REALMS-10537
Unfortunately I forgot to unsub to this issue, so I read a few comments that I'm obligated to respond to.
@LucienHH I can join the exact same realm with the same two accounts on proper clients with no issues. The moment one of the clients is one of yours things start failing. There is clearly an issue with something in prismarine - I don't think it's worthwhile to shift the blame.
@extremeheat I've uninstalled Node and have no intention of using Prismarine in the future so I'm not able to help contribute any further. The first post on the issue includes everything you need to repro the fault including a realm invite.
(Also, if you're encouraging people to dump the DEBUG output of your application, you should be providing extra configuration to obfuscate tokens. Otherwise, you're just luring people into compromising their accounts).
I think listening to chat stopped working again in 1.19.11 realms. It no longer logs packets. Nothing is being printed to console and I have process.env.DEBUG = 'minecraft-protocol'
at the top of the script
- The client won't get chat messages if it has not spawned. The
spawn
event will be triggered as mentioned in our documentation. - If this issue has happened because your client has not spawned, then you should provide a proxy log as mentioned prior.
The client is spawning in properly as the spawn
event is being emitted. It console logs a string when spawn
is emitted
OK, if the client spawns then it should be able to correctly receive chat messages. Can you reproduce this on other servers? If not, this certainly seems to be an issue on server side (see Lucien's links to bug reports on the topic).
I think listening to chat stopped working again in 1.19.11 realms. It no longer logs packets. Nothing is being printed to console and I have
process.env.DEBUG = 'minecraft-protocol'
at the top of the script
I also have some packages that are not displayed after the update
Quick, get someone who knows nothing about how to fix the issue to debug everything.
OK, if the client spawns then it should be able to correctly receive chat messages. Can you reproduce this on other servers? If not, this certainly seems to be an issue on server side (see Lucien's links to bug reports on the topic).
It is working on my BDS which is running 1.19.10. my realm running 1.19.11 is not logging chat packets at all.
No updates to this, closing. Seems this is a Realms issue as it cannot be reproduced outside of Realms and happens to non-bedrock-protocol clients also - https://bugs.mojang.com/browse/REALMS-9150. Please re-open if this you think is a confirmed issue with bedrock-protocol specifically.