venomous0x / WhatsAPI

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

whatsapi php daemon disconnect ... #985

Open scramatte opened 9 years ago

scramatte commented 9 years ago

Hi,

I've embed whatsapi into a php daemon. My issue is that I'm unable to keep online 24x7 the bot. After inactive time bot appears disconnected.

I'm running latest version. I've tried various thing such sendGetPrivacyBlockedList but still doesn't works. Does anybody has got a working example ?

dennobaby commented 9 years ago

SendPresence and pollMessage in a while-loop.

My daemon runs for days without problems...

Von Samsung Mobile gesendet

ludufre commented 9 years ago

@dennobaby, My bot works perfect. Can handle a lot of conversations during the day and for days. My doubt is, what the correct frequency of send of these commands? Today I sent pollMessage() every second and the sendPresence every ten seconds. It's okay, or need to be more slowly? It's only estetic, already works as is.

scramatte commented 9 years ago

Can you post example code ?

ludufre commented 9 years ago

@scramatte Well, I imaginated you already have a working code and have a main while as well, then you need to put the $w->sendPresence(); on this loop.

scramatte commented 9 years ago

Just this ? ... I've just add it above pollMessage. I'm must wait now to see if it works or not. Thank you

dennobaby commented 9 years ago

$t=0; while (1) { $w->pollMessage(); $msgs = $w->getMessages(); foreach ($msgs as $m) { //do something }

  if( ($t == 15)){
      $w->sendPresence();
      $t=0;
  }       
  $t++;

}

mgp25 commented 9 years ago

Take a look to /test folder, whatsapp.php