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

Ping timeout #502

Open
1 task
981726 opened this issue Jun 2, 2024 · 3 comments
Open
1 task

Ping timeout #502

981726 opened this issue Jun 2, 2024 · 3 comments

Comments

@981726
Copy link

981726 commented Jun 2, 2024

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

Versions

  • mineflayer: #.#.#
  • server: vanilla/spigot/paper #.#.#
  • node: #.#.#

Detailed description of a problem

i am using bedrock multi instance and one of my accounts keeps ping timeing out and it randomly stops

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

const bedrock = require('bedrock-protocol');

// Configuration
const serverHost = 'donutSMP.net'; // The Bedrock server you want to connect to
const serverPort = 19132; // The port of the Bedrock server

// Define account configurations
const accounts = [
    {
        username: 'hiqril',
    },
    {
        username: 'raxFR',
    }
];

// Function to create a client for a single account
function createAndConnectClient(account) {
    // Create a client to connect to the Bedrock server
    const client = bedrock.createClient({
        host: serverHost,
        port: serverPort,
        username: account.username,
        offline: false, // Set to true to enable offline mode
    });

    // Handle successful connection
    client.on('connect', () => {
        console.log(`Connected to server as ${account.username}`);
    });

    // Handle the 'spawn' event
    client.on('spawn', () => {
        console.log(`${account.username} has spawned on the server.`);
    });

    // Handle connection errors
    client.on('error', (error) => {
        console.error(`Connection error for ${account.username}:`, error);
    });

    // Handle Reconnect errors
    client.on('end', () => {
        console.log(`${account.username} disconnected from the server. Reconnecting...`);
        createAndConnectClient(account);
    });

    // Add more event listeners here as needed
}

// Connect each account to the server
function connectBothAccounts() {
    for (const account of accounts) {
        createAndConnectClient(account);
    }
}

// Start the connection process for both accounts
connectBothAccounts();

Expected behavior

to both accounts launch and not timeout every few hours

Additional context

when it times out i sometimes have to wait long hours 6+

@extremeheat extremeheat transferred this issue from PrismarineJS/mineflayer Jun 2, 2024
@extremeheat
Copy link
Member

extremeheat commented Jun 2, 2024

This is because the server is unreachable. You need to make sure you can connect with a vanilla client when you get that error. If it works sometimes, it could be an temporary issue with the server.

@981726
Copy link
Author

981726 commented Jun 3, 2024

This is because the server is unreachable. You need to make sure you can connect with a vanilla client when you get that error. If it works sometimes, it could be an temporary issue with the server.

it works fine in java and bedrock its just that it crashes / timeout

@DhyanCanPlay
Copy link

bro just use mineflayer cz you have a java server

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

No branches or pull requests

3 participants