Failing on large number of pushes

522 views
Skip to first unread message

astoni...@gmail.com

unread,
Dec 4, 2012, 4:35:57 PM12/4/12
to apns...@googlegroups.com
I have an issue that I cannot trace down.  Hoping someone can give some insight.  We have a database of users of our app who subscribe to certain things.  We have pushes that go out everyday based on these subscriptions.

I have a cron job that runs periodically and pulls the appropriate subscribers, gets their tokens and runs them through apns-php.  When I load the subscribers I record in a db table how many should send.  Then I open the connection and send them, and then record the result of how many went through.  This works most of the time, but then fails on a large number of pushes.  I have had success sending up to 1220.  Then somewhere between there and 2500 it fails.  It seems that some of the pushes do go out before it fails.  I do not get any error messages and I've been unable to find a way to capture data to point me in the right direction. 

Answers that may help:  Is there a limit to how many I can send through at a time?  Should I batch this somehow and open/close the connection with each batch?  Is there some way after $push->send(); to get information about any errors that may be happening?  Will it kick out somehow if there is a bad token in the list?  Any hints would be appreciated.

astoni...@gmail.com

unread,
Dec 26, 2012, 10:17:46 AM12/26/12
to apns...@googlegroups.com, astoni...@gmail.com
Well, I guess this forum is the no helping kind.

ma...@mike-tucker.com

unread,
Jan 7, 2013, 8:25:28 AM1/7/13
to apns...@googlegroups.com, astoni...@gmail.com
I have the same problem and am trying to come up with a solution.
The most likely issue is that the server is timing out-- this usually occurs after 2 minutes or so.

I think I'll try a hack that involves using ajax to send ~1000 messages per call,
and repeat that call indefinitely until the queue is at zero.

Will let you know what i find...

astoni...@gmail.com

unread,
Jan 29, 2013, 12:08:43 PM1/29/13
to apns...@googlegroups.com, astoni...@gmail.com
Mike, Thanks for the input and good luck with your issue.  I have max_execution_time set to 3600 which is an hour.  I know the script runs less than two minutes, usually less than one.  So not sure if that is my issue, unless you are talking about another factor.

Since this original post I decided to try to batch them in a loop.  I connect, gather the tokens, divide by 1000, load them in the queue and send a max of 1000 at a time and then disconnect once after all.  I had on fail today on a target count of 955 so it didn't even have to loop.  I looked in my php error_log and found this:

[29-Jan-2013 16:00:14 UTC] PHP Fatal error:  Uncaught exception 'ApnsPHP_Push_Exception' with message 'No notifications queued to be sent' in /home/qponrevo/public_html/admin/push/ApnsPHP/Push.php:129
Stack trace:
#0 /home/qponrevo/public_html/admin/cron-qbot-push.php(315): ApnsPHP_Push->send()
#1 {main}
  thrown in /home/qponrevo/public_html/admin/push/ApnsPHP/Push.php on line 129

Here is that portion of the script in push.php of APNSphp
        if (empty($this->_aMessageQueue)) {
            throw new ApnsPHP_Push_Exception(    // this is line 129
                'No notifications queued to be sent'
            );
        }

I'm not sure what this means.  I know the pushes were queued because I received the push.  So at least some of them went out.  The problem remains that I do not know how many of the 955 went out before it fails.

I'm still looking.  Let me know if you find anything.  Are you getting any error messages in the log?

astoni...@gmail.com

unread,
Mar 8, 2013, 2:34:34 PM3/8/13
to apns...@googlegroups.com, astoni...@gmail.com
Still looking for a solution.  I set up a test with feedback today, running the script in a browser window and having it print some results.  The query pulled 10,454 members to send the push to.  I now have it set up to run batches of 1000 thinking that would help.  In my output screen it ran the first 6 batches meaning 6000 pushes sent (I received it to my phone).  Then, when it started batch 7 it stopped running and yielded:


Fatal error: Uncaught exception 'ApnsPHP_Push_Exception' with message 'No notifications queued to be sent' in /home/qponrevo/public_html/admin/push/ApnsPHP/Push.php:129 Stack trace: #0 /home/qponrevo/public_html/admin/test.php(321): ApnsPHP_Push->send() #1 {main} thrown in /home/qponrevo/public_html/admin/push/ApnsPHP/Push.php on line 129


I just can't find a solution to this.  The error makes it sound like there were no messages queued, but the first 6 batches queued and ran so the programming of queuing the batches of tokens passes inspection.  Has anyone run into this and found a way around?

astoni...@gmail.com

unread,
Mar 9, 2013, 3:55:32 PM3/9/13
to apns...@googlegroups.com, astoni...@gmail.com
This issue is resolved.  I broke it up in batches of 1000 to send.  Then I used a series of try/catch and checking to make sure a token was present before queuing and together all of this made it pass all the messages.  Up to nearly 12,000 have been tested successfully.

adity...@gmail.com

unread,
Aug 19, 2013, 8:52:14 AM8/19/13
to apns...@googlegroups.com, astoni...@gmail.com
Can you please provide me your source code with Ajax to try, I hope you won't mind? Please let me know ASAP

nit....@gmail.com

unread,
Dec 22, 2013, 1:45:44 PM12/22/13
to apns...@googlegroups.com, astoni...@gmail.com

can you please share the source code?
Reply all
Reply to author
Forward
0 new messages