zendframework / ZendService_Apple_Apns

BSD 3-Clause "New" or "Revised" License
49 stars 70 forks source link

It sends the APN but hangs until execution time is expired #19

Closed german-chosen closed 9 years ago

german-chosen commented 9 years ago

The thing is that I receive the notification, but the script just continue running.

This is what I got when using ZF2 (it doesn't happen all the time, I can say):

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

cvuorinen commented 9 years ago

I have the same problem. Just hangs there with 100% CPU while trying to read the socket stream with fread. This happens when using a valid token and the actual push notification is delivered to my device. When using fake token the code works and immediately returns status code 8 (invalid token).

At first I thought it was the same issue as here: http://stackoverflow.com/questions/7501289/php-fread-hangs-when-using-ssl But socket_get_status says there are 0 unread bytes, even with the invalid token when there actually is stuff to read and the fread works.

Anybody have any idea what might be causing this? Is this a bug in PHP or something? I'm on a Ubuntu machine with PHP v5.6.7.

cvuorinen commented 9 years ago

On a CentOS server with PHP v5.4.16 the same code executes nicely without any delay, so it looks like the issue is with Ubuntu or the newer PHP version. I think I'll file a bug report for PHP, just need to figure out some minimal code example to reproduce it.

mwillbanks commented 9 years ago

@cvuorinen is the debian / ubuntu server running suhosin or something random like that?

cvuorinen commented 9 years ago

@mwillbanks no, nothing special like that.

I have tested this on a few different CentOS servers, running PHP 5.4, 5.5 and 5.6 and all work correctly. And on a Debian server running PHP 5.4 which also works. So it definitely seems to be something environment specific. The Ubuntu machine where it doesn't work is my development machine so it's not a really big issue for me right now, but I'll see if I can find any other machine where the issue can be reproduced and then maybe get a better idea what's causing it.

ghost commented 9 years ago

Also started seeing this on a new server. Ubuntu 14.04.2, PHP 5.6.7

cvuorinen commented 9 years ago

@danielstqry OK, seems to be something about that environment then, I also have Ubuntu 14.04 and PHP 5.6.7.

ghost commented 9 years ago

Compiled PHP 5.6.6 and 5.6.7 for comparison. Works fine on 5.6.6 but not 5.6.7

5.6.6: 0.13 seconds 5.6.7 60.13 seconds

5.6.7 with a timeout:

ini_set('default_socket_timeout', 10);

10.22 seconds.

cvuorinen commented 9 years ago

Thanks for the info. I have filed a bug about this: https://bugs.php.net/bug.php?id=69402

cvuorinen commented 9 years ago

FYI, this should be fixed in upcoming PHP versions (5.5.25 and 5.6.9). You can check the comments in the bug report for more details if interested.

ghost commented 9 years ago

What a pain that a fix won't make it into 5.6.8. I wonder if you had any ideas about rolling back to 5.6.6 with apt-get on Ubuntu? I'm using PPA ondrej/php5-5.6 and it doesn't seem possible.

RileyMills commented 9 years ago

For what it's worth I just ran into this issue in a Laravel Homestead VM on 5.6.7 and upgrading PHP to 5.6.9 resolved the issue. This one was an interesting one to track down, so thanks for finally pointing me in the right direction guys.

potsky commented 9 years ago

Same problem on Centos 6.6 with PHP 5.5.24. No more problem on 5.5.26 :-)