N
N
nastyskafomka2019-01-05 02:35:35
PHP
nastyskafomka, 2019-01-05 02:35:35

User LongPoll how long will the script run?

Hello, with this code

$activ = true;
while ($activ = true) {
    $longPoll = $vk->Messages()->getLongPollServer($token); //Получаем данные сервера LongPoll
    $data = "https://{$longPoll['server']}?act=a_check&key={$longPoll['key']}&ts={$longPoll['ts']}&wait=25&mode=2&version=3";
    $d = file_get_contents($data); // Получаем последние события аккаунта (сообщения и тд)
}

I receive events from the LongPoll VK server, the question is this:
Here I have a script that constantly requests data from the server, is it possible that at one moment I will not receive a response from VK?
It's just that I have this script running in the background on the server, and I don't really want to constantly climb there and restart it.
Thanks in advance for your reply.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Shumov, 2019-01-05
@inoise

Yes, LongPoll can break. For a million reasons. So better use Callback instead

S
Stockholm Syndrome, 2019-01-05
@StockholmSyndrome

just so nothing should break
in the worst case, the server may return errors that can be handled

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question