edamov / pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key)
MIT License
369 stars 119 forks source link

Sometimes message not send to all the device tokens #35

Closed lipflip closed 5 years ago

lipflip commented 6 years ago

Sometimes (5 out of 10 times) not all messages were send to all the devicetokens.

We discovered that sometimes the connection breaks in the while loop in Client.php without any reason. After investigation we discovered adding this line solves the problem:

... while (($execrun = curl_multi_exec($mh, $running)) == CURLM_CALL_MULTI_PERFORM);

if ($execrun != CURLM_OK) { break; }

//ADDED THIS AFTER CURLM_OK if ($running && curl_multi_select($mh) === -1) { usleep(250); }

while ($done = curl_multi_info_read($mh)) { ...

Don't know why. But after we had made this change, we hadn't had issues anymore. Hope this helps someone.

Curl version: 7.52.1

grizzly commented 6 years ago

this also worked for me! thanks for that!

eerison commented 5 years ago

It's happen to me too :/

eerison commented 5 years ago

Sorry my problem is I was with my app open and when I send message don't show to me... But when I outside app works normally :)