Skip to content
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

pickRealm silently fails to connect #1302

Open
B2H990 opened this issue Apr 7, 2024 · 6 comments · May be fixed by #1303
Open

pickRealm silently fails to connect #1302

B2H990 opened this issue Apr 7, 2024 · 6 comments · May be fixed by #1303

Comments

@B2H990
Copy link

B2H990 commented Apr 7, 2024

'use strict'

const mineflayer = require('mineflayer')

const [,, username, realmName] = process.argv
if (!realmName) {
  console.log('Usage : node client_realms.js <username/email> <realm_name>')
  process.exit(1)
}

const client = mineflayer.createBot({
  realms: {
    pickRealm: (realms) => realms.find(e => e.name === realmName) // Connect the client to a Realm using a function that returns a Realm
  },
  username,
  auth: 'microsoft' // This option must be present and set to 'microsoft' to  join a Realm.
})

client.on('connect', function () {
  console.info('connected')
})

client.on('disconnect', function (packet) {
  console.log('disconnected: ' + packet.reason)
})

prints connected, but never actually connects to realm.

@extremeheat
Copy link
Member

extremeheat commented Apr 7, 2024

cc @LucienHH

@B2H990
Copy link
Author

B2H990 commented Apr 7, 2024

This works:

const bot = mineflayer.createBot({
	host: 'realhost',
	realms: {
		pickRealm: (realms) => realms[0]
	},
	auth: 'microsoft'
})

But not this:

const bot = mineflayer.createBot({
	realms: {
		pickRealm: (realms) => realms[0]
	},
	auth: 'microsoft'
})

@extremeheat
Copy link
Member

That is strange since the realm handling will replace the host and port with the correct one. Can anyone else with realms reproduce?

@extremeheat
Copy link
Member

If you can still repro with latest, can you add process.env.DEBUG = '*' to the top of your code and provide the debug console output?

@B2H990
Copy link
Author

B2H990 commented May 25, 2024

I am able to reproduce the issue on latest. The debug log has sensitive information that I would rather not post publicly on a github issue. Is there another way I can send it to you?

@extremeheat
Copy link
Member

Ah, I think I see the issue. We're not waiting for realm auth (where host information gets deduced) inside https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/src/createClient.js#L50 before loading the other plugins (so at their init time there is indeed no host/port which can cause problems).

I'll transfer the issue to nmp

@extremeheat extremeheat transferred this issue from PrismarineJS/mineflayer May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants