Cannot handle deserialization error for individual packets
Using createClient, when protodef fails to deserialize a packet, the whole client shuts down, and does not allow me to handle expected malformed packets.
I'm not sure if this should be fixed in protodef or nmp.
Versions: minecraft-protocol 1.11.0, protodef 1.6.10, minecraft-data 2.50.0
If you listen to error event it should not crash
What emitter do I need to listen on? I'm listening on Client and the deserializer is already listened to in minecraft-protocol/src/client.js:66 (setSerializer).
Minimal example:
const mcProto = require('minecraft-protocol')
const client = mcProto.createClient({
host: process.env.MC_HOST || "localhost",
username: process.env.MC_USERNAME || "McProto",
password: process.env.MC_PASSWORD,
})
process.on("unhandledRejection", err => {
console.error(`[ERROR] process.unhandledRejection error=${err}`)
console.error(err)
})
process.on("uncaughtException", err => {
console.error(`[ERROR] process.uncaughtException error=${err}`)
console.error(err)
})
process.on("warning", err => {
console.error(`[WARNING] process.warning error=${err}`)
console.error(err)
})
client.on('error', err => {
console.error(`[ERROR] error error=${err}`)
console.error(err)
})
client.on('kicked', packet => {
console.error(`[ERROR] kicked reason=${packet.reason}`)
})
client.on('end', payload => {
console.error(`[ERROR] end reason=${payload}`)
})
client.on('disconnect', packet => {
console.error(`[ERROR] disconnected reason=${packet.reason}`)
})
client.on('close', () => {
console.error(`[ERROR] connection closed`)
})
client.on('timeout', () => {
console.error(`[ERROR] connection timeout`)
})
let pos
client.on('position', packet => {
pos = packet
if (packet.teleportId) {
client.write('teleport_confirm', { teleportId: packet.teleportId })
}
})
client.once('position', () => {
this.tickInterval = setInterval(() => {
client.write('position_look', { onGround: true, ...pos })
}, 50)
})
I got the following error trying to connect to a server using 1.14.4 as client version: https://paste.lucko.me/ROwYEVJ811 I used the example code in the README file.
Can you post the server too
On Sun, May 31, 2020, 02:39 Gabriele C. [email protected] wrote:
I got the following error trying to connect to a server using 1.14.4 as client version: https://paste.lucko.me/ROwYEVJ811 I used the example code in the README file.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/node-minecraft-protocol/issues/709#issuecomment-636403610, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437SRUS4IVQUF7RXJBULRUGRLNANCNFSM4M2PW3KA .
The server was play.tecnocraft.net
client.on('error', () => {}) works fine for me
I'm having the same issue,client.on('error', () => {}) doesn't stop the process from crashing
my server has fabric mods
https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/src/client.js#L68 this shouldn't be a pb