PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
5.09k stars 921 forks source link

Bot crashing #2702

Open GaspardCulis opened 2 years ago

GaspardCulis commented 2 years ago

Versions

Detailed description of a problem

I am trying to connect multiple bots to the same server, around about 20, using the gps.js example, I run multiple instances of them using & in my terminal, and if I ask them to "come", they become very laggy and start to crash with this error message :

Error: write EPIPE at afterWriteDispatched (node:internal/stream_base_commons:160:15) at writeGeneric (node:internal/stream_base_commons:151:3) at Socket._writeGeneric (node:net:817:11) at Socket._write (node:net:829:8) at writeOrBuffer (node:internal/streams/writable:389:12) at _write (node:internal/streams/writable:330:10) at Socket.Writable.write (node:internal/streams/writable:334:10) at Framer.ondata (/root/programmation/javascript/minecraft-bots/tests/node_modules/readable-stream/lib/_stream_readable.js:681:20) at Framer.emit (node:events:527:28) at addChunk (/root/programmation/javascript/minecraft-bots/tests/node_modules/readable-stream/lib/_stream_readable.js:298:12) { errno: -32, code: 'EPIPE', syscall: 'write' }

I am running this one of OCI (Oracle Cloud Infrastructure) Vms so I guess internet speed isn't the issue. For me on my computer I do not get disconnected so I guess it isn't the server's fault

I think from a network standpoint it should be possible, as I know softwares such as OQMinebot that can handle more than 20 bots at the same time with no lag.

kashalls commented 2 years ago

Looks like they all start to write data all at the same time, causing the connection to close instead of replying. I was able to reproduce this a couple of months back as I was running each bot in its own "cluster" thread. Not sure what exactly causes this, as it happened even on local loopback.

rom1504 commented 2 years ago

How is the CPU usage?

On Sat, Jul 23, 2022, 13:41 Jordan Jones @.***> wrote:

Looks like they all start to write data all at the same time, causing the connection to close instead of replying. I was able to reproduce this a couple of months back as I was running each bot in its own "cluster" thread. Not sure what exactly causes this, as it happened even on local loopback.

— Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/mineflayer/issues/2702#issuecomment-1193111588, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437V3V7V6YLWEI6A6B6TVVPK43ANCNFSM532B2P4Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

GaspardCulis commented 2 years ago

Used cpu-usage package, 20%...

GaspardCulis commented 2 years ago

Looks like they all start to write data all at the same time, causing the connection to close instead of replying. I was able to reproduce this a couple of months back as I was running each bot in its own "cluster" thread. Not sure what exactly causes this, as it happened even on local loopback.

How could we fix that, maybe put the bots in some BotNetworkSyncGroup class or something like that, and queue the packets to send ?

GaspardCulis commented 2 years ago

Or maybe having an option to select the SRC port of the connection (while keeping 25565 as the DST port) so we can run each bot on his own port

mollthecoder commented 1 year ago

I'm having a similar problem, with only one bot. I added a pathfinding command in my bot and it keeps crashing with the error "Error: write EPIPE".

mollthecoder commented 1 year ago

I've determined the crash has something to do with swimming in water.

mollthecoder commented 1 year ago

I'm going to create an issue on the pathfinder's github, as this probably isn't mineflayer's fault.