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

Error: read ECONNRESET #3228

Closed
1 task done
Atom1cByte opened this issue Nov 9, 2023 · 2 comments
Closed
1 task done

Error: read ECONNRESET #3228

Atom1cByte opened this issue Nov 9, 2023 · 2 comments
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@Atom1cByte
Copy link

Atom1cByte commented Nov 9, 2023

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

Versions

  • mineflayer: 4.14.0
  • server: spigot
  • node: v18.16.1

Detailed description of a problem

I'm essentially trying to create a bot that automatically kicks a player from the server when they join (without operator permissions)
When I run it, it kicks the player at first, but then, once the player rejoins, they don't get kicked anymore and the code proceeds to give this error:

Error: read ECONNRESET
    at TCP.onStreamRead (node:internal/stream_base_commons:217:20) {
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read'
}

My current code

const mineflayer = require("mineflayer")

bot = []
error_handler = []

function createBot() {
  console.log("bot made")
  bot[0] = mineflayer.createBot({
    host: "<my ip>",
    port: 43274,
    username: "<username of person who i aim to get kicked>",
  });

  bot[0].on("error", (err) => {console.log(err);createBot();});
  bot[0].on("end", () => {console.log("reconnecting..");createBot()});
}

createBot();

// Everything after this is irrelevant to the error (i think)

function lookAtNearestPlayer() {
  const playerFilter = (entity) => entity.type === "player";
  const playerEntity = bot[0].nearestEntity(playerFilter);

  if (!playerEntity) return;

  const pos = playerEntity.position.offset(0, playerEntity.height, 0);
  bot[0].lookAt(pos);
}

bot[0].on("physicTick", lookAtNearestPlayer);

Expected behavior

I expect it to kick the player whenever they rejoin the server.

@Atom1cByte Atom1cByte added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Nov 9, 2023
@LukeTheNeko
Copy link
Contributor

I have the same problem using the bot on VPS

@extremeheat
Copy link
Member

This is caused by the server or something in your network between you and the server. Basically you are being disconnected by someone, and if it's the server, they are closing your connection without sending a Minecraft kick packet. You can't fix this in your code until you figure out if it's the server or the network, so check the server logs and see if you can reproduce on another Minecraft server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

3 participants