Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out of memory #27

Closed
efeferrari opened this issue Sep 14, 2017 · 15 comments
Closed

Out of memory #27

efeferrari opened this issue Sep 14, 2017 · 15 comments

Comments

@efeferrari
Copy link

Hello @Edujugon,

I getting Out Of Memory error sending push to iOS.

image

I tried with develop and production url of Apple, but is always same error.

PHP v5.6.30
edujugon/push-notification: v2.2.0

@efeferrari efeferrari changed the title Out of memoey Out of memory Sep 14, 2017
@Edujugon
Copy link
Owner

Hi @efeferrari
Have you tried to test it in other environment?

@efeferrari
Copy link
Author

I tried in local and development environments. In both, I set ini_set memory_limit to 1 GB.

@Drozes
Copy link

Drozes commented Sep 25, 2017

Same issue, Any luck on finding a fix for this?

@efeferrari
Copy link
Author

I try with a new iOS certificate and works fine, but it's still a bug get an "Out of memory" instead an "invalid certificate" 🤔

@Edujugon
Copy link
Owner

Edujugon commented Sep 27, 2017

Hi @efeferrari @Drozes ,
I'm really busy these days and I'm not able to check out this issue.

For now, as @efeferrari said , you can generate a new certificate and try with it. It's not the first time that generating a new certificate solves some issues..

@Dolaned
Copy link

Dolaned commented Nov 20, 2017

Hi also having this issue with a new cert, anyone find the issue?

@Edujugon
Copy link
Owner

Hi @gl3nda85 ,

Could you try to call apnsFeedback() method and see if it returns any token?
Notice that method returns a list of tokes that should be removed from the deviceToken list to send the notification.
Then, try again to send the notification.

Let me know if that helped

@danielz0
Copy link

Hi Edujugon,
I am experiencing kind of the same error: when trying to send pushes to APN the php starts consume memory, freezes and at the end I got "PHP Fatal error: Allowed memory....".
The feedback() method is not even called because all freezes on send().

Any clue?

Best,
Daniel

Laravel 5.2, PHP 7.0

@Edujugon
Copy link
Owner

Hi @danielz0 ,

In the next days I'll dig deeply into this issue. Would you share your certificate with me so I could do tests with that one as well? if so, send me a mail to edujugon@gmail.com

In the meantime, have you tried to generate a new Certificate? most probably is Apple who is refusing the connection to its server..

@danielz0
Copy link

Hi again,
I am sorry to say, but the same certificate used on another server works totally fine.
I have traced this for errors and I am sure that
class Apn extends PushService implements PushServiceInterface
public function send(array $deviceTokens,array $message)
is the one which generates problem.

In details I have two servers with Laravel 5.2 and PHP7.0
Both were working fine, until one day one of it stopped sending iOS pushes.

After days of tracing the only thing I got is
Symfony\Component\Debug\Exception\FatalErrorException: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in /default/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:59

I have tried all tricks, from modules update to increasing memory limits - no luck so far.
When using strace I can see that the Apple push service returns 'operation in progress' all the time which increasing occupied memory and finally leads to memory exception.

Not sure, but personally I think it might be something connected with system libraries.

I am going to generate list of files your process is trying to open on both servers and compare.

Any suggestions are welcome.

Thanks!
Daniel

@danielz0
Copy link

Maybe this will help you?

Strace:
[pid 27958] 19:53:56 recvmsg(12, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"\24\0\0\0\3\0\2\0\244\253\25Z6m\0\0\0\0\0\0", 4096}], msg_controllen=0, msg_flags=0}, 0) = 20 [pid 27958] 19:53:56 close(12) = 0 [pid 27958] 19:53:56 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 12 [pid 27958] 19:53:56 connect(12, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("17.188.135.152")}, 16) = 0 [pid 27958] 19:53:56 getsockname(12, {sa_family=AF_INET, sin_port=htons(40476), sin_addr=inet_addr("46.101.111.122")}, [16]) = 0 [pid 27958] 19:53:56 connect(12, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 [pid 27958] 19:53:56 connect(12, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("17.188.129.28")}, 16) = 0 [pid 27958] 19:53:56 getsockname(12, {sa_family=AF_INET, sin_port=htons(56513), sin_addr=inet_addr("46.101.111.122")}, [16]) = 0 [pid 27958] 19:53:56 connect(12, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 [pid 27958] 19:53:56 connect(12, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("17.188.137.23")}, 16) = 0 [pid 27958] 19:53:56 getsockname(12, {sa_family=AF_INET, sin_port=htons(40665), sin_addr=inet_addr("46.101.111.122")}, [16]) = 0 [pid 27958] 19:53:56 connect(12, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 [pid 27958] 19:53:56 connect(12, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("17.188.135.148")}, 16) = 0 [pid 27958] 19:53:56 getsockname(12, {sa_family=AF_INET, sin_port=htons(59539), sin_addr=inet_addr("46.101.111.122")}, [16]) = 0 [pid 27958] 19:53:56 connect(12, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 [pid 27958] 19:53:56 connect(12, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("17.188.130.23")}, 16) = 0 [pid 27958] 19:53:56 getsockname(12, {sa_family=AF_INET, sin_port=htons(56115), sin_addr=inet_addr("46.101.111.122")}, [16]) = 0 [pid 27958] 19:53:56 connect(12, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 [pid 27958] 19:53:56 connect(12, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("17.188.141.156")}, 16) = 0 [pid 27958] 19:53:56 getsockname(12, {sa_family=AF_INET, sin_port=htons(54942), sin_addr=inet_addr("46.101.111.122")}, [16]) = 0 [pid 27958] 19:53:56 connect(12, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 [pid 27958] 19:53:56 connect(12, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("17.188.135.26")}, 16) = 0 [pid 27958] 19:53:56 getsockname(12, {sa_family=AF_INET, sin_port=htons(37714), sin_addr=inet_addr("46.101.111.122")}, [16]) = 0 [pid 27958] 19:53:56 connect(12, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0 [pid 27958] 19:53:56 connect(12, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("17.188.130.157")}, 16) = 0 [pid 27958] 19:53:56 getsockname(12, {sa_family=AF_INET, sin_port=htons(43001), sin_addr=inet_addr("46.101.111.122")}, [16]) = 0 [pid 27958] 19:53:56 close(12) = 0 [pid 27958] 19:53:56 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 12 [pid 27958] 19:53:56 fcntl(12, F_GETFL) = 0x2 (flags O_RDWR) [pid 27958] 19:53:56 fcntl(12, F_SETFL, O_RDWR|O_NONBLOCK) = 0 [pid 27958] 19:53:56 connect(12, {sa_family=AF_INET, sin_port=htons(2195), sin_addr=inet_addr("17.188.135.152")}, 16) = -1 EINPROGRESS (Operation now in progress)

This EINPROGRESS (Operation now in progress) lasts couple of minutes depend on how big is the memory limit and results in:
Symfony\Component\Debug\Exception\FatalErrorException: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in /default/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:59 Stack trace: #0 {main}

@danielz0
Copy link

Hi @Edujugon
I think I found the problem which might be here reactphp/stream#64
Let me know your thoughts.

Best,
Daniel

@Edujugon
Copy link
Owner

Edujugon commented Nov 23, 2017

Hi @danielz0 ,
Thank you for your support, I really appreciate it :)

Have you tested it in PHP 7.1.4 or 7.0.18 ? Does that work for you?

It seems to have a work-around for PHP < 7.1.4 (and PHP < 7.0.18) but since it has a performance penalty it may be the reason of that issue.

I have to test it in different PHP versions with a big data/payload to send.

@danielz0
Copy link

danielz0 commented Nov 23, 2017

Hi @Edujugon,
Didn't have time to test this in php7.1.4 nor in 7.0.18, but will do it next week, as I plan to update at least one of my servers. For now I am using self-written script which chunks data into smaller sets.

The payload which crashed in my case contains 1000tokens and one-two lines in the message body.

Best,
Daniel

@Edujugon
Copy link
Owner

The new releases (3.x & 2.2.x) prevent of this error.
I'm closing this issue. feel free to open it again if the error persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants