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

Index out of range #46

Closed
ghost opened this issue Jan 5, 2016 · 16 comments
Closed

Index out of range #46

ghost opened this issue Jan 5, 2016 · 16 comments

Comments

@ghost
Copy link

ghost commented Jan 5, 2016

Basicly when I run my bot I get this:

C:\Users\Name\node_modules\agario-client\agario-client.js:415
// If you need that server support, you may create issue https://github.com/pulviscriptor/agario-client/issues
^

RangeError: index out of range
at checkOffset (buffer.js:642:11)
at Buffer.readUInt16LE (buffer.js:688:5)
at Object.Packet.readUInt16LE (C:\Users\Name\node_modules\agario-client\packet.js:51:29)
at Client.processors.49 (C:\Users\Name\node_modules\agario-client\agario-client.js:342:39)
at Object.Client.onMessage (C:\Users\Name\node_modules\agario-client\agario-client.js:140:9)
at WebSocket.onMessage (C:\Users\Name\node_modules\agario-client\node_modules\ws\lib\WebSocket.js:414:14)
at emitTwo (events.js:87:13)
at WebSocket.emit (events.js:172:7)
at Receiver.onbinary (C:\Users\Name\node_modules\agario-client\node_modules\ws\lib\WebSocket.js:804:10)
at C:\Users\Name\node_modules\agario-client\node_modules\ws\lib\Receiver.js:533:18

@pulviscriptor
Copy link
Owner

Usually this kind on crash happens when agar.io changes protocol.
I run examples/basic.js for 20 minutes and can't reproduce crash.
How often you see that crash?
Does it happens in examples?
Did you updated your agario-client? (last protocol-change-fix that caused "random" crashes was Nov 29, 2015)

@pulviscriptor
Copy link
Owner

Running examples/multiple.js for 3+ hours with 5 clients connected, still no crashes.
If somebody else have crashes please report them here.

@ghost
Copy link
Author

ghost commented Jan 6, 2016

@pulviscriptor It may be that I'm running 50+ bots

@pulviscriptor
Copy link
Owner

DrTheGoat, how often you see crashes?

@ghost
Copy link
Author

ghost commented Jan 6, 2016

@pulviscriptor Within minutes of running

@pulviscriptor
Copy link
Owner

@DRTHEGOAT Can you set debug to 5 and show me last 5 packets before crash?

@pulviscriptor
Copy link
Owner

@DRTHEGOAT You can run script like node bot.js > debug.log and then look in debug.log

@ghost
Copy link
Author

ghost commented Jan 6, 2016

@pulviscriptor Thanks

@DaAwesomeRazor
Copy link

I get that every day it crashes all the time

@DaAwesomeRazor
Copy link

It happens when i run like 60 bots for a long time(I made bots too)

@pulviscriptor
Copy link
Owner

@DaAwesomeRazor Please set client.debug = 5; and show me last 5 packets so i can see packet that causes crash.
Output will be huge so run script like node bot.js > debug.log and then get last lines from debug.log

@ghost
Copy link
Author

ghost commented Jan 7, 2016

@pulviscriptor 10 05 00 43 3d 02 00 3f 7f 02 00 52 70 02 00 ec 82 02 00 cb 63 02 00 b9 7b 02 00 74 fa 00 00 5d 87 02 00 6a 6a 02 00 17 84 02 00 dc 6f 02 00 a7 08 00 00 46 e8 ff ff 75 00 3d 07 ff 00 00 00 52 70 02 00 23 0c 00 00 19 e7 ff ff ac 01 4e 07 ff 00 00 00 f9 71 02 00 b7 0e 00 00 6e e8 ff ff 38 01 4e 07 ff 00 00 00 00 00 00 00 01 00 00 00 ec 82 02 00
SEND packet ID=0 LEN=23
dump: 00 53 00 65 00 72 00 76 00 65 00 72 00 20 00 52 00 61 00 69 00 64 00
RECV packet ID=49 LEN=187
dump: 31 0a 00 00 00 e5 42 02 00 00 00 72 bb 01 00 73 00 61 00 6e 00 69 00 6b 00 00 00 20 02 02 00 6d 00 65 00 00 00 89 66 01 00 6e 00 61 00 73 00 61 00 33 00 35 00 00 00 0e 12 02 00 44 00 79 00 44 00 20 00 4d 00 61 00 6d 00 61 00 64 00 6f 00 75 00 00 00 6a 48 02 00 4e 00 65 00 74 00 68 00 65 00 72 00 6c 00 61 00 6e 00 64 00 73 00 00 00 58 4a 02 00 62 00 61 00 6e 00 67 00 6c 00 61 00 64 00 65 00 73 00 68 00 00 00 98 f8 01 00 73 00 6d 00 61 00 72 00 74 00 79 00 30 00 32 00 82 7e 00 7f 10 07 00 5a 69 02 00 02 85 02 00 84 88 02 00 13 6f 02 00 1f 87 02 00 a2 86 02
C:\Users\Dream_000\node_modules\agario-client\agario-client.js:415
// If you need that server support, you may create issue https://github.com/pulviscriptor/agario-client/issues
^

RangeError: index out of range
at checkOffset (buffer.js:642:11)
at Buffer.readUInt16LE (buffer.js:688:5)
at Object.Packet.readUInt16LE (C:\Users\Dream_000\node_modules\agario-client\packet.js:51:29)
at Client.processors.49 (C:\Users\Dream_000\node_modules\agario-client\agario-client.js:342:39)
at Object.Client.onMessage (C:\Users\Dream_000\node_modules\agario-client\agario-client.js:140:9)
at WebSocket.onMessage (C:\Users\Dream_000\node_modules\agario-client\node_modules\ws\lib\WebSocket.js:414:14)
at emitTwo (events.js:87:13)
at WebSocket.emit (events.js:172:7)
at Receiver.onbinary (C:\Users\Dream_000\node_modules\agario-client\node_modules\ws\lib\WebSocket.js:804:10)
at C:\Users\Dream_000\node_modules\agario-client\node_modules\ws\lib\Receiver.js:533:18

@pulviscriptor
Copy link
Owner

@DRTHEGOAT Thank you very much! This is exact packet that i need!
After investigating i see strange thing here.
This is packet ID 49 and here is processor from original code http://pastebin.com/raw/LbfZAPw3
So i made port of it http://pastebin.com/raw/VX2buBmD
It is crashing and this is what i see https://i.imgur.com/94E8s3s.png
But if i move offset one byte forward before leaders = []; i will get this https://i.imgur.com/lQcdIbl.png
Sooooo...

@DRTHEGOAT @DaAwesomeRazor somehow your packets got one byte more/less of data. I don't know how that is possible.
I assume you use SOCKS servers so lets think its SOCKS servers breaking packets somehow.
I think i will add something like event for packet errors so you can handle them from your code.
I will try to do it today.

@pulviscriptor
Copy link
Owner

@DRTHEGOAT @DaAwesomeRazor
Event client.on.packetError(packet, err, preventCrash) added. Check readme.
Example of usage:

bot.on('packetError', function(packet, err, preventCrash) {
   bot.log('Packet error detected for packet: ' + packet.toString());
   bot.log('Crash will be prevented, bot will be disconnected');
   preventCrash();
   bot.disconnect();
});

*My fix is not best solution, but i don't know what else i can do with bytes changes.

@issy123
Copy link

issy123 commented Feb 13, 2016

You probably edited agario-client.js in the node modules?
or you named the argument variable name wrong for example:

bot.on('packetError', function(packet, err, preventCrash) {
   bot.log('Packet error detected for packet: ' + packet.toString());
   bot.log('Crash will be prevented, bot will be disconnected');
   preventCahs();
   bot.disconnect();
});

What also could be possible is that you got the number of arguments wrong

bot.on('packetError', function(packet, preventCrash) {
   bot.log('Packet error detected for packet: ' + packet.toString());
   bot.log('Crash will be prevented, bot will be disconnected');
   preventCrash();
   bot.disconnect();
});

But it should be this:

bot.on('packetError', function(packet, err, preventCrash) {
   bot.log('Packet error detected for packet: ' + packet.toString());
   bot.log('Crash will be prevented, bot will be disconnected');
   preventCrash();
   bot.disconnect();
});

feel free to join this skype group:
https://join.skype.com/eQuN52iQVzZg
for more small questions.
i'm active there :)

@DRSDavidSoft
Copy link
Contributor

Connecting to ws://77.223.145.110:1420
worker: [warning] You did not specified "key" for Client.connect(server, key)
          If server will not accept you, this may be the problem
worker: connecting...
worker: connected to server
worker: SEND packet ID=254 LEN=5
worker: dump: fe 05 00 00 00
worker: SEND packet ID=255 LEN=5
worker: dump: ff 23 12 38 09
worker: spawning
worker: spawn() called, name=agario-client
worker: SEND packet ID=0 LEN=27
worker: dump: 00 61 00 67 00 61 00 72 00 69 00 6f 00 2d 00 63 00 6c 00 69 00 65 00 6e 00 74 00
worker: Starting spawn() interval
worker: RECV packet ID=16 LEN=1615
worker: dump: 10 00 00 48 0f 36 00 31 08 ce 09 a7 02 c3 f0 00 00 5b 00 20 00 50 00 43 00 4c 00 20 00 5d 00 20 00 50 00 69 00 63 00 63 00 6f 00 6c 00 6f 00 00 00 4e 12 36 00 2a 0e 5b 0a 0a 00 37 5c ff 00 00 00 2a 13 36 00 63 0d 3c 09 0a 00 eb 4b 00 00 00 00 3a 14 36 00 dc 0e f9 09 0a 00 50 f5 00 00 00 00 25 15 36 00 68 0c 95 0c 0a 00 50 91 00 00 00 00 9f 16 36 00 74 0c e5 09 0a 00 37 5c ff 00 00 00 9f 18 36 00 4a 0e 58 0e 0a 00 b4 5a 87 00 00 00 47 19 36 00 00 0d ee 0a 0a 00 b4 5a 87 00 00 00 e5 19 36 00 0f 0f 78 0b 0a 00 50 f5 00 00 00 00 46 1a 36 00 38 0c 9f 0d 0a 00 c3 f0 00 00 00 00 de 1a 36 00 95 0c 94 0b 0a 00 50 f5 00 00 00 00 c9 1c 36 00 8e 0b 2e 0d 0a 00 b4 07 14 00 00 00 a4 1d 36 00 a6 0c e4 0b 0a 00 a5 19 00 00 00 00 a9 1d 36 00 6a 0d c9 0b 0a 00 b4 5a 87 00 00 00 bd 1d 36 00 44 0d c0 0d 0a 00 50 f5 00 00 00 00 19 1e 36 00 57 0e fc 07 0a 00 eb 4b 00 00 00 00 20 1e 36 00 73 0f d2 0b 0a 00 b4 07 14 00 00 00 28 1e 36 00 b1 0c 10 0d 0a 00 37 5c ff 00 00 00 8f 1f 36 00 b0 0f 4f 09 0a 00 b4 07 14 00 00 00 2b 20 36 00 c2 0c 9e 0c 0a 00 e1 7d ff 00 00 00 2c 20 36 00 16 0f 99 0a 0a 00 b4 07 14 00 00 00 60 20 36 00 08 0c c4 09 0a 00 b4 5a 87 00 00 00 67 20 36 00 2c 0e 65 0b 0a 00 b4 07 14 00 00 00 76 20 36 00 a2 0c 3e 0e 0a 00 96 12 ff 00 00 00 17 21 36 00 41 0f fa 08 0a 00 50 aa f0 00 00 00 27 21 36 00 b3 0b b7 09 0a 00 eb 4b 00 00 00 00 46 21 36 00 75 0d 86 0e 0a 00 50 aa f0 00 00 00 5f 21 36 00 c1 07 98 0c 0a 00 96 12 ff 00 00 00 d4 21 36 00 47 0b 16 0a 0a 00 50 aa f0 00 00 00 f4 21 36 00 c4 0d 39 0e 0a 00 c3 f0 00 00 00 00 11 22 36 00 bf 0a 57 0e 0a 00 b4 5a 87 00 00 00 2a 22 36 00 ed 0d d2 0a 0a 00 b4 07 14 00 00 00 a5 22 36 00 29 0d a9 0b 0a 00 50 aa f0 00 00 00 cf 22 36 00 de 0d 26 0a 3f 00 c3 f0 00 00 5b 00 20 00 50 00 43 00 4c 00 20 00 5d 00 20 00 50 00 69 00 63 00 63 00 6f 00 6c 00 6f 00 00 00 d0 22 36 00 50 0e f8 09 3d 00 c3 f0 00 00 5b 00 20 00 50 00 43 00 4c 00 20 00 5d 00 20 00 50 00 69 00 63 00 63 00 6f 00 6c 00 6f 00 00 00 d1 22 36 00 10 0e 90 09 3e 00 c3 f0 00 00 5b 00 20 00 50 00 43 00 4c 00 20 00 5d 00 20 00 50 00 69 00 63 00 63 00 6f 00 6c 00 6f 00 00 00 d2 22 36 00 d2 0d 2b 09 3a 00 c3 f0 00 00 5b 00 20 00 50 00 43 00 4c 00 20 00 5d 00 20 00 50 00 69 00 63 00 63 00 6f 00 6c 00 6f 00 00 00 d3 22 36 00 4b 0d 80 08 3a 00 c3 f0 00 00 5b 00 20 00 50 00 43 00 4c 00 20 00 5d 00 20 00 50 00 69 00 63 00 63 00 6f 00 6c 00 6f 00 00 00 db 22 36 00 59 0b 32 07 72 01 c3 f0 00 00 5b 00 20 00 50 00 43 00 4c 00 20 00 5d 00 20 00 50 00 69 00 63 00 63 00 6f 00 6c 00 6f 00 00 00 13 23 36 00 38 0f 03 0d 0a 00 50 f5 00 00 00 00 2b 23 36 00 c0 09 2b 0d 0a 00 e1 7d ff 00 00 00 5b 23 36 00 4a 0d 06 0e 0a 00 37 5c ff 00 00 00 b9 23 36 00 c7 0d 52 0f 2d 00 b4 07 14 00 6c 00 6c 00 6c 00 6c 00 6f 00 6f 00 6f 00 6f 00 6c 00 6c 00 6c 00 6c 00 00 00 4d 24 36 00 b5 08 39 0f 0a 00 50 aa f0 00 00 00 f6 24 36 00 38 0c 1b 09 0a 00 50 f5 00 00 00 00 26 25 36 00 81 0a 3b 0d 0a 00 50 f5 00 00 00 00 b8 25 36 00 f9 0e a1 0e 0a 00 b4 07 14 00 00 00 da 25 36 00 4f 0e 89 0b 0a 00 a5 19 00 00 00 00 df 25 36 00 70 0d 42 09 0a 00 50 aa f0 00 00 00 aa 27 36 00 98 0c 40 0f 0a 00 96 12 ff 00 00 00 cf 27 36 00 03 0f 90 0a 0a 00 e1 7d ff 00 00 00 f3 27 36 00 85 0b b3 0c 0a 00 c3 f0 00 00 00 00 05 28 36 00 4b 09 54 0e 0a 00 c3 f0 00 00 00 00 7e 28 36 00 14 0e 88 0d 0a 00 50 f5 00 00 00 00 aa 28 36 00 4b 08 36 0d 0a 00 c3 f0 00 00 00 00 d0 28 36 00 da 08 4b 0f 0a 00 e1 7d ff 00 00 00 f7 28 36 00 50 0a 40 0f 0a 00 96 12 ff 00 00 00 fc 28 36 00 e9 0b 6d 0d 0a 00 50 aa f0 00 00 00 ee 29 36 00 ec 0a 0a 09 0a 00 eb 4b 00 00 00 00 03 2a 36 00 d5 0d d2 0b 0a 00 b4 5a 87 00 00 00 10 2a 36 00 e9 0d 68 0b 0a 00 96 12 ff 00 00 00 64 2a 36 00 61 0c 2f 09 0a 00 b4 5a 87 00 00 00 70 2a 36 00 2a 0f a3 0e 0a 00 50 aa f0 00 00 00 48 0f 36 00 31 08 ce 09 a7 02 c3 f0 00 00 5b 00 20 00 50 00 43 00 4c 00 20 00 5d 00 20 00 50 00 69 00 63 00 63 00 6f 00 6c 00 6f 00 00 00 cf 22 36 00 de 0d 26 0a 3f 00 c3 f0 00 00 5b 00 20 00 50 00 43 00 4c 00 20 00 5d 00 20 00 50 00 69 00 63 00 63 00 6f 00 6c 00 6f 00 00 00 d0 22 36 00 50 0e f8 09 3d 00 c3 f0 00 00 5b 00 20 00 50 00 43 00 4c 00 20 00 5d 00 20 00 50 00 69 00 63 00 63 00 6f 00 6c 00 6f 00 00 00 d1 22 36 00 10 0e 90 09 3e 00 c3 f0 00 00 5b 00 20 00 50 00 43 00 4c 00 20 00 5d 00 20 00 50 00 69 00 63 00 63 00 6f 00 6c 00 6f 00 00 00 d2 22 36 00 d2 0d 2b 09 3a 00 c3 f0 00 00 5b 00 20 00 50 00 43 00 4c 00 20 00 5d 00 20 00 50 00 69 00 63 00 63 00 6f 00 6c 00 6f 00 00 00 d3 22 36 00 4b 0d 80 08 3a 00 c3 f0 00 00 5b 00 20 00 50 00 43 00 4c 00 20 00 5d 00 20 00 50 00 69 00 63 00 63 00 6f 00 6c 00 6f 00 00 00 db 22 36 00 59 0b 32 07 72 01 c3 f0 00 00 5b 00 20 00 50 00 43 00 4c 00 20 00 5d 00 20 00 50 00 69 00 63 00 63 00 6f 00 6c 00 6f 00 00 00 b9 23 36 00 c7 0d 52 0f 2d 00 b4 07 14 00 6c 00 6c 00 6c 00 6c 00 6f 00 6f 00 6f 00 6f 00 6c 00 6c 00 6c 00 6c 00 00 00 00 00 00 00 00 00 00 00
worker: action: ball_id=3542856 coordinate_x=164497457 coordinate_y=-255655257 size=0 is_virus=false nick=PCL ] Piccolo
worker: Packet error detected! Check packetError event in README.md

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

4 participants