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

Packet Errors #56

Closed
DaAwesomeRazor opened this issue Jan 14, 2016 · 29 comments
Closed

Packet Errors #56

DaAwesomeRazor opened this issue Jan 14, 2016 · 29 comments

Comments

@DaAwesomeRazor
Copy link

when i run 70 132 mass bots this is the packet error i get

Packet error detected for packet: 10 0c 00 a5 88 28 00 e2 a7 29 00 5c d5 28 00 8d a5 29 00 59 a9 29 00 e5 a2 29 00 f1 57 29 00 ef a8 29 00 e5 97 29 00 80 a7 29 00 ca 87 00 00 00 47 a6 29 00 71 0b 00 00 3b ec ff ff 39 00 07 ff 71 00 00 00 4d a6 29 00 cd 0e 00 00 bc e9 ff ff 72 00 fe ff 07 00 00 00 00 a7 29 00 3c 0e 00 00 8e f0 ff ff 20 00 07 79 ff 00 00 00 d0 a7 29 00 56 05 00 00 e9 ec ff ff 0b 00 74 ff 07 00 00 00 e1 a7 29 00 9e fe ff ff a1 ed ff ff f6 04 20 07 ff 00 00 00 f9 a7 29 00 ee 08 00 00 c6 ed ff ff 39 00 07 ff 71 00 00 00 fa a7 29 00 5c 09 00 00 3a ee ff ff 39 00 07 ff 71 00 00 00 fb a7 29 00 e8 08 00 00 3a ee ff ff 39 00 07 ff 71 00 00 00 3a a8 29 00 e3 0d 00 00 c9 eb ff ff 43 00 ff 07 9c 00 00 00 00 00 00 00 02 00 00 00 29 90 29 00 22 94 29 00 82 7e 01 97 10 0c 00 45 a7 29 00 85 9d 29 00 f1 57 29 00 f3 a8 29 00 75 5a 29 00 db 9b 29 00 97 8a 29 00 88 a2 29 00 78 71 29 00 67 a5 29 00 86 94 29 00 78 a9 29 00 86 94 29 00 7b a9 29 00 5a 9c 29 00 7a a9 29 00 3d 1f 29 00 6f a9 29 00 3d 1f 29 00 6e a9 29 00 3d 1f 29 00 70 a9 29 00 1b a4 29 00 33 a8 29 00 5c d5 28 00 b8 07 00 00 5f f2 ff ff b6 02 07 ff df 00 00 00 c1 68 29 00 ca 07 00 00 0e ec ff ff 8f 00 82 07 ff 00 00 00 26 8e 29 00 8a 06 00 00 12 ee ff ff ec 00 76 07 ff 00 00 00 c6 9c 29 00 6f 0d 00 00 fe f0 ff ff 74 00 54 07 ff 00 00 00 5d 9d 29 00 38 08 00 00
35 says: Crash will be prevented, bot will be disconnected
C

This really needs to get fixed because it happens all the time. I think its internet because it doesnt happen when I run it on vps

@pulviscriptor
Copy link
Owner

@DaAwesomeRazor
While i porting code of agar for test, can you tell

  • what Node.js version you use
  • what OS
  • do you use SOCKS
  • show npm list output

@pulviscriptor
Copy link
Owner

@DaAwesomeRazor
While i'm writing my investigation here, try to update ws to latest. You can do npm update to update outdated agario-client too. But that packet from first message is corrupted, so outdated agario-client is not the reason. But it may fix second message (about crash).
Lets see if updating ws will fix anything. Do npm update

@pulviscriptor
Copy link
Owner

Investigation results

Ported only first part (packet ID 16 part 1)
agar.io: http://pastebin.com/raw/vwSm5Tx3 (code used http://pastebin.com/raw/C4xSJDwy )
Simulation on agario-client: http://pastebin.com/raw/i5GZUb8N (code used http://pastebin.com/raw/Xy5YGQhx ) (first byte removed since its ID)
IDs are the same. No bugs in code.
But you got very cool packet. There is 12 eating events (eaters_count=12) that have very simple structure

//reading eat events
for(var i=0;i<eaters_count;i++) {
    var eater_id = packet.readUInt32LE(); //<-- reading 4 bytes
    var eaten_id = packet.readUInt32LE(); //<-- reading 4 bytes
                                          // NO MORE READING AT ALL!
    ...

and problem is somewhere between 5 and 6 and we see that valid IDs starting with 26 and 27
Adding bytes gave nothing.
I even went to bits level.
Converting http://pastebin.com/raw/e17TJYZE
Testing http://pastebin.com/raw/JSx19EBe
Shows same broken IDs without changes.
And you know what? Adding/removing bits gave nothing.
Who wants to try himself, add/remove bits like this http://pastebin.com/raw/QMXPyugs
Adding/removing 32 bits should be enough for bruteforcing all possibilities since we bruteforcing one readUInt32LE() call.
And i tried to get any strings from data http://pastebin.com/raw/ypfdzEw9 (via adding bits) and i did not got any strings/nicknames.

No valid IDs, no strings, no nothing. I don't understand where that data came from and how it got stuck inside packet.

@DaAwesomeRazor
Copy link
Author

Ok still getting error, even though I updated the websocket

@pulviscriptor
Copy link
Owner

Is it error "Packet error detected for packet" or "throw new RangeError('Trying to access beyond buffer length');"?

@DaAwesomeRazor
Copy link
Author

throw new RangeError('Trying to access beyond buffer length

@DeepSnowNeeL
Copy link

Told you guys, it's packet de-sync. It looks like socks lib or nodejs can't
handle too much packets without desync sometimes. Remember node.js is
monothread so if it uses ~15% of a 8 core computer, it is already at max
cpu and can't keep up with the number of packets incomming from many bots.

Le jeu. 14 janv. 2016 22:47, DaAwesomeRazor [email protected] a
écrit :

throw new RangeError('Trying to access beyond buffer length

Reply to this email directly or view it on GitHub
#56 (comment)
.

@DaAwesomeRazor
Copy link
Author

@DeepSnowNeeL Yeah its probably socks because i can run that many bots using localAddress and its fine

@DaAwesomeRazor
Copy link
Author

@pulviscriptor This needs to be fixed because I cant run my bots without being crashed every 5 minutes

@pulviscriptor
Copy link
Owner

@DeepSnowNeeL
I am sure its not Node.js
Its that socks lib, or ws lib, or SOCKS servers by themselves, or my code somewhere, or maybe agar.io sending some garbage sometimes, who knows.
@DaAwesomeRazor

being crashed every 5 minutes

Are you using on.packetError(packet, err, preventCrash) and still getting crash?

Since you have stable crashes, can i ask you try other SOCKS agents? You can google "node.js socks agent" and try some other lib than socks from there.
If its too hard for you to code, i can write code for you.

@pulviscriptor
Copy link
Owner

@DaAwesomeRazor
Wait, i decided to find whats wrong myself. I will write what i found here.
I may ask you for some details later.

@pulviscriptor
Copy link
Owner

After few hours having fun and dominating with bots i can say, ws is crashing like crazy.
I will look what i can do with it, but now at least i can reproduce issue.

@DaAwesomeRazor
Copy link
Author

Can I send you my script? and you tell me whats wrong? My script crashes a ton. When i updated ws it stopped the index out of range thing. But im still getting the buffer length. Im 95% sure its Socks5 because when I use localAddress it works fine. But localAddress is a pain in the ass so..

@harrydevelop
Copy link

@DaAwesomeRazor hei can i send you a script maybe its yours but it work great ,there are only one problem with this websocket ws://razor.secureobscure.com:6578
http://pastebin.com/raw/3ff3uFyn

@pulviscriptor
Copy link
Owner

@DaAwesomeRazor
I can reproduce your problem. I also think there is memory leak, and i need some time to find whats wrong.
But first i want to play with bots little more 😋

@DaAwesomeRazor
Copy link
Author

@pulviscriptor I think It is a problem with wifi. Something that the packets arent being sent on time. I dont get as many errors on my vpns, but when i use crappy internet the problems start.

@DaAwesomeRazor
Copy link
Author

@harrydevelop Thats my script... It wont help me I already know what it does..Plus you need my bot servers :P

@pulviscriptor
Copy link
Owner

@DaAwesomeRazor
You can add try catch block in WebSocket.js for code that crashes for temporary fix.
For example this one of crashes WebSocket.js line 425

  function onError (event) {
    event.type = 'error';
    event.target = target;
    listener.call(target, event);
  }

do it

  function onError (event) {
   try {
    event.type = 'error';
    event.target = target;
   }catch(e){
    //we don't care
   }
   listener.call(target, event);
  }

And fix all those crashes. It will work as temporary solution.

@DaAwesomeRazor
Copy link
Author

@pulviscriptor K I will try that

@harrydevelop
Copy link

@DaAwesomeRazor if it dosent work i can ask to my university professor ,tell you tomorrow what is wrong :)

@pulviscriptor
Copy link
Owner

@DaAwesomeRazor
Do try catch on them all. And again, its temporary solution.

@DaAwesomeRazor
Copy link
Author

@pulviscriptor You think because im just using a lot of bots and really crappy socks proxies?

@Sonicmaster13
Copy link

try {} catch(e) {} wont work. We tried it, and no matter what we still keep getting errors like:

event.target = target;
             ^

TypeError: Cannot assign to read only property 'target' of reserved fields must be empty
at WebSocket.onError (C:\Users\clock\Desktop\RSBotz\node_modules\ws\lib\WebSocket.js:422:18)
at emitTwo (events.js:87:13)
at WebSocket.emit (events.js:172:7)
at Receiver.onerror (C:\Users\clock\Desktop\RSBotz\node_modules\ws\lib\WebSocket.js:832:10)
at Receiver.error (C:\Users\clock\Desktop\RSBotz\node_modules\ws\lib\Receiver.js:317:8)
at Receiver.processPacket (C:\Users\clock\Desktop\RSBotz\node_modules\ws\lib\Receiver.js:191:12)
at Receiver.add (C:\Users\clock\Desktop\RSBotz\node_modules\ws\lib\Receiver.js:91:24)
at Socket.firstHandler (C:\Users\clock\Desktop\RSBotz\node_modules\ws\lib\WebSocket.js:774:22)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)

@pulviscriptor
Copy link
Owner

You think because im just using a lot of bots and really crappy socks proxies?

Here what i can say for you.
I use this code

var last_interval = (+new Date);

setInterval(function(){
    var now = (+new Date);
    console.log('delay: ' + (now-last_interval-interval) + 'ms');
    last_interval = now;
}, 100);

When delay reaches OVER 250 MILLISECONDS ws crashes. I was able to get delays over 1000ms for one run. Its crazy.
And even if you start fixed amount of bots, first delays will be 0-1ms, but will slowly increasing. So i think there is memory leak.
I will investigate more, if this is problem in ws i will create issue there.

try {} catch(e) {} wont work. We tried it, and no matter what we still keep getting errors

It will work. You just getting new errors over and over again. I do not how much there places in code that causes crash.
You can keep adding try catch or wait for my solution, which i don't know at the moment.

@DaAwesomeRazor
Copy link
Author

@pulviscriptor Ok so we saw that in the websocket code that there was throw new error. We replaced that with a console.log('websocket error!') so I dont think there are any more errors. I havent got any in a while.

@pulviscriptor
Copy link
Owner

Lets keep it open until ws gets fixed so peoples can see how to fix it until then.

@pulviscriptor pulviscriptor reopened this Jan 23, 2016
@DaAwesomeRazor
Copy link
Author

@pulviscriptor K

@DaAwesomeRazor DaAwesomeRazor changed the title Found out how to recreate the pakcet error Packet Errors Jan 23, 2016
@DaAwesomeRazor
Copy link
Author

Just started using a new socks proxy list. Im already getting less packet errors

@pulviscriptor
Copy link
Owner

ws finally got updated npm package. No more manual patching required, upgrade your agario-client to 1.3.6

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

5 participants