Open ghost opened 10 years ago
Hello! I think is better that you connect, collect messages, logout every x minutes, you can programming a cron task for this work
Saludos Jesús Sales
El 16/01/2014, a las 19:25, Matthijs Otterloo notifications@github.com escribió:
Hi,
I've a problem. The bot keeps online for max 1 hour. After this hour the bot goes offline and doesn't come back online. It only goes offline if i reload the script. How can i fix this?
Grtz,
Matthijs
— Reply to this email directly or view it on GitHub.
Okay, so i have to make a cron job to restart the script every few seconds?
I'm able to stay logged in for days without disconnecting. How often are you polling? Are you responding to the ping messages?
This is my code: http://pastebin.com/ZGyBDD0Z 123 are placeholders..... What do i have to change in my code to fix this?
Increase the value in
set_time_limit(10);
in line 2.
e.g.
set_time_limit(300);//5 minutes
@shirioko what if i want the bot 24/7 online?
24h per day over 7 days
Saludos Jesús Sales
El 19/01/2014, a las 22:54, Matthijs Otterloo notifications@github.com escribió:
@shirioko what if i want the bot 24/7 online?
— Reply to this email directly or view it on GitHub.
Nope, changing the set_time_limit(10); to set_time_limit(300); doesn't work…. Any other ideas?
What does your debug output say?
Well? What is the best way to stop it from stopping, and have the bot running forever? set_time_limit(0) and change php max_execution time to 0?
and sendPresence so it doesnt close socket
How do you set up sendPresence? I havent come across that function yet...
whatsprot.class for more info
$w->sendPresence();
Thanks. So would I need to run the function every so often? I am guessing that this function needs to keep being called every now and again....
sendPresence() won't keep you online.
@shirioko @mgp25 This seems to be a common request/question. "How do we stay connected", i.e Keep the connection or "BOT" from going offline.
Can we please get a definitive answer. Thanks.
EDIT: in my tests, sendPresence() with no other activity, sent once every 60secs will keep you online for 10 mins MAX
I already addressed this issue in WhatsApiNet
i use WhatsApiNet, i am having the same issue, can you please point to the write usage?
thanks.
Why dont you search it in WhatsApiNet repo instead of asking here?
seen. thanks.
@cahrlesokwuagwu before you gallop off into the sunset....could you share where you "seen" it. Thanks!
@8DigitalStaging Find it in WhatsApiNet repo, the information is in there, why dont you search there?
I am but a link to the exact one would be so much quicker.....
I know, but people needs to start searching for themselfes
for all those who come here searching https://github.com/perezdidac/WhatsAPINet/issues/116
But still all that code is .net Is there no simple solution in PHP? keepAlive() function or something? This is the last peice to my puzzle and is vital for my project to work.
You dont know how to search... here
There are workarounds, but you can code it the way you want
Thanks. The .net version is calling SendGetPrivacySettings() which does not exist in the PHP version. I am assuming I can use any sendget function desired just to keep server communication open?
No you can use sendGetPrivacyBlockedList instead
Thanks. Testing the threading I have extended processnode function with thread and now it throws an error on the class saying class not found. Fatal error: Class 'ProcessNode' not found
Can this class not be extended to use threading?
PHP can't use threading.
trying to use pthread
How else could you do it without using threading? Your example in .net uses threads
PHP != C#
Just like how any processor does it, using interrupts based on timers
$interval = 60;//seconds
$start = time();
while(true)
{
$wa->pollMessage();
$now = time();
if($now > ($start + $interval))
{
//tick
$wa->sendGetPrivacyBlockedList();
$start = time();//reset timer
}
}
Also, PHP < C#
Thanks for all your help. Much appreciated! Now I get this error notice: fwrite(): send of 12 bytes failed with errno=32 And the script stops. Could it be my php max exec time timing out? Not sure why this is. I have tried using sendPresence to get rid of the stream:error error, tried to use sendPong but still its stopping with the notice above. Any Ideas?
Never mind. Figured it out. Sorted. Thanks.
Hi,
I've a problem. The bot keeps online for max 1 hour. After this hour the bot goes offline and doesn't come back online. It only goes offline if i reload the script. How can i fix this?
Grtz,
Matthijs