0

I am trying to make a web server for the Mineflayer API for my coding project. It is hosted using the free plan on render.com, and I use a cron job to keep it awake. However, when I send the bot creation request to it, it gives this error, and then continues execution:

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

I tried looking for errors in my code, but I have not found any. The server goes through a switch statement to determine which path to take, and this one is triggered:

case "create":
  let [username, ip, port] = data.split(","); // For now, we only support offline mode.
  let id = crypto.randomBytes(32).toString('hex');
  let bot = mineflayer.createBot({username: username || `Bromine_${id.slice(0, 8)}`, host: ip, port: (port || 25565)});
  bot.messages = [];
  bot.on("message", function(msg, pos) {this.messages.push({jsonMsg: msg, position: pos})});
  bots[id] = {bot: bot};
  var response = {success: true, id: id};
  break;

Edit

The error message is sometimes longer, and may contain more information:

Error: write ECONNRESET
    at afterWriteDispatched (node:internal/stream_base_commons:160:15)
    at writeGeneric (node:internal/stream_base_commons:151:3)
    at Socket._writeGeneric (node:net:962:11)
    at Socket._write (node:net:974:8)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10)
    at Writable.write (node:internal/streams/writable:337:10)
    at Framer.ondata (/opt/render/project/src/node_modules/minecraft-protocol/node_modules/readable-stream/lib/internal/streams/readable.js:705:22)
    at Framer.emit (node:events:517:28)
    at addChunk (/opt/render/project/src/node_modules/minecraft-protocol/node_modules/readable-stream/lib/internal/streams/readable.js:321:12)
{
  errno: -104,
  code: 'ECONNRESET',
  syscall: 'write'
}
9
  • How do you send the request? Where do you see this error and is that the complete stack trace? Commented Apr 9, 2024 at 15:12
  • @JensV To test it, I sent the request through a web browser. I see this error in the render logs. Commented Apr 9, 2024 at 15:14
  • And that's the only thing you see? Because that error message seems way too short Commented Apr 9, 2024 at 15:17
  • @JensV Of the error, yes. There is the chance the render logs aren't showing the full error. Commented Apr 9, 2024 at 15:18
  • Does it work when you run it locally or only when deployed? Are you also sure that the server you're connecting to is reachable from there? Commented Apr 9, 2024 at 15:21

2 Answers 2

0

It seems the error is the equivalent of the connection reset error that can occur when trying to join a Minecraft server. The issue probably came from using an aternos server, since the actual server it is hosted on changes every time.

Sign up to request clarification or add additional context in comments.

Comments

0

For us it didn't work with the latest Minecraft Client version. We went down to 1.21.1 and explicitly provided version: '1.21.1' on mineflayer setup and it worked flawlessly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.