venomous0x / WhatsAPI

Interface to WhatsApp Messenger
2.59k stars 2.13k forks source link

Invalid token #551

Open Fidelity88 opened 10 years ago

Fidelity88 commented 10 years ago

From time to time I keep getting this error:

PHP Fatal error:  Uncaught exception 'Exception' with message 'BinTreeNodeReader->readListSize: Invalid token 31' in /home/********/public_html/whatsapp/protocol.class.php:392
Stack trace:
#0 /home/********/public_html/whatsapp/protocol.class.php(346): BinTreeNodeReader->readListSize(31)
#1 /home/********/public_html/whatsapp/protocol.class.php(280): BinTreeNodeReader->nextTreeInternal()
#2 /home/********/public_html/whatsapp/whatsprot.class.php(2057): BinTreeNodeReader->nextTree()
#3 /home/********/public_html/whatsapp/whatsprot.class.php(1490): WhatsProt->processInboundData('??????A????????...')
#4 /home/********/public_html/whatsapp/whatsprot.class.php(420): WhatsProt->doLogin(false)
#5 /home/********/public_html/run.php(20): WhatsProt->loginWithPassword('***********...')
#6 {main}
  thrown in /home/********/public_html/whatsapp/protocol.class.php on line 392

What is causing this and how can I fix this?

RFKDOT commented 10 years ago

Post some code. ¿You use "$w->eventManager()->bind(???,???) into a while?

Fidelity88 commented 10 years ago

No the eventmanager is called oustide of the while loop.

[...]
$w = new WhatsProt($username, 0, "xxxxxx", false);
$w->eventManager()->bind("onGetMessage", "onMessage");
$w->eventManager()->bind("onGetImage", "onImage");
$w->connect();
$w->loginWithPassword($password);

$time=1;
while($time <= 40)
{
    if ($time <= 5) {
        $w->pollMessages();
    } else {
[...]

Since sending and receiving can't be done simultaneously, I always look for new messages the first 5 seconds. Then I process outgoing messages if there are any. When that is done I look for new messages again until the time run == 40 seconds :)

RFKDOT commented 10 years ago

This is mi script very reduced to only receipt msgs y have test:

<?php
define('PATH', '/home/admon/WB');

require PATH.'/src/WhatsAPI/src/php/whatsprot.class.php';
require PATH.'/config.php';

$w = new WhatsProt(SEND, IMEI, NICK, DEBUG);
$w->Connect();
$w->LoginWithPassword(PASS);

$w->eventManager()->bind("onGetMessage", "GetMessage");

function GetMessage($mynumber, $from, $id, $type, $time, $name, $body){
       echo $mynumber.'|'.$from.'|'.$id.'|'.$type.'|'.$time.'|'.$name.'|'.$body."\n";
       //process de msg

}

while(TRUE){

      $w->PollMessages();
      sleep(1);

}
?>
ghost commented 10 years ago

https://github.com/venomous0x/WhatsAPI/issues/456

Fidelity88 commented 10 years ago

So nobody actually knows what this error is causing is my conclusion now... I'm getting this error even when not receiving or sending out messages, so it would have nothing to do with the content or the time between messages.

RFKDOT commented 10 years ago

I don't understand, but my script are online 3 months and always works perfectly. Receive messages, video and images from 7 groups with 6-30 participants simultaneously. Sorry for my English

Fidelity88 commented 10 years ago

It does work! But I keep getting errors. I can just ignore the errors, but rather fix it :)

shirioko commented 10 years ago

Are you running multiple WhatsProt objects in the same script? WhatsProt class has some static properties used for encryption which don't allow multiple instances of WhatsProt at the same time.

Fidelity88 commented 10 years ago

Nope, only 1. So kinda weird I still get errors

scramatte commented 10 years ago

Same issue here. I'm using ProcessNode class and method "setNewMessageBind"
If you send messages too quickly , I catch following exceptions messages.

2014-01-25T13:32:19+01:00 INFO (6): BinTreeNodeReader->readListSize: Invalid token 154 2014-01-25T13:32:20+01:00 INFO (6): BinTreeNodeReader->readListSize: Invalid token 5 2014-01-25T13:32:21+01:00 INFO (6): BinTreeNodeReader->readListSize: Invalid token 31 2014-01-25T13:32:22+01:00 INFO (6): BinTreeNodeReader->readListSize: Invalid token 79 2014-01-25T13:32:23+01:00 INFO (6): BinTreeNodeReader->readListSize: Invalid token 180

escalanterj commented 10 years ago

Hello, does somebody know why do I get this?

PHP Fatal error: Call to undefined method WhatsProt::Message() in /var/whatsapp/whatsapp_whatsapi_send.php on line 14

shirioko commented 10 years ago

It's because your code is horribly outdated. Method names were changed like a year ago?