Sends the notification but hangs until execution time is expired
Had the same problem with ZF2, thought that using this library would solve the problem. The thing is that I receive the notification, but the script just continue running. I occurs only sometimes.
This is what I got using the ApnsPHP library (got them in the log file):
INFO: Trying ssl://gateway.push.apple.com:2195... INFO: Connected to ssl://gateway.push.apple.com:2195. INFO: Sending messages queue, run #1: 1 message(s) left in queue. STATUS: Sending message ID 1 custom identifier: bk-1418832690-57: 185 bytes.
This is what I got when using ZF2:
PHP Warning: fread(): SSL: Invalid argument in .../ZendService/Apple/Apns/Client/AbstractClient.php on line 156 PHP Fatal error: The request was aborted because it exceeded the maximum execution time. in .../ZendService/Apple/Apns/Client/AbstractClient.php on line 156
Update:
Maybe it's important. I couldn't manage how to use the Entrust Root Certification Authority, it failed when I tried to send a push notification.
Update:
Found a similar problem report in a forked repository. He proposed to use the following lines before using the $this->_hSocket:
$stream_meta_data=stream_get_meta_data($this->_hSocket); if ($stream_meta_data['unread_bytes']<=0) { return; }
https://github.com/benguild/ApnsPHP/compare/duccio:master...master
My case was that script hanged only if it tried to get response of apns. You should just write to a stream\socket and close it.