ibiren / php-apns Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/php-apns
Automatically exported from code.google.com/p/php-apns
Whenever PushMonitor.php gets a message from the queue, it gives me this error
"Error while
starting child process"
I've followed the installation instructions.
My specs:
PHP 5.2.6 running on CentOS release 5.2 (Final) on my MediaTemple VPS
Any suggestions?
Original issue reported on code.google.com by [email protected]
on 27 Jun 2009 at 1:02
What steps will reproduce the problem?
1. sending a message
2. waiting for the PushMonitor to kill the service process
What is the expected output? What do you see instead?
Expect the service process to be killed, instead app just hangs
What version of the product are you using? On what operating system?
Debian
Please provide any additional information below.
I suspect the code in process::kill() which seems to have been copied from the
PHP docs doesn't get the child process IDs from the
parent PID correctly.
The line :
$pids = preg_split('/\s+/', `ps -o pid --no-heading --ppid $ppid`);
makes no sense to me as the preg split should surely be on the output of the
command 'ps -o pid --no-heading --ppid $ppid' not the
command line itself.
Is there a reason we need to find child PIDs? From what I can see the
PushService.php file doesnt open any child processes.
Ive replaced the function with the following code which works for me:
public function kill()
{
global $debug;
$status = proc_get_status($this->pointer);
print_r($status);
if($status['running'])
{
if($debug)
echo 'proc is running...closing pipes.';
fclose($this->pipes[0]);
fclose($this->pipes[1]);
fclose($this->pipes[2]);
$ppid = $status['pid'];
proc_terminate($this->pointer);
return (proc_close($this->pointer) == 0);
}
}
I'm not sure if I need the proc_close condition on return.
Original issue reported on code.google.com by [email protected]
on 28 Aug 2009 at 11:54
The use of PHP_NORMAL_READ in PushService.php appears to cause PushService.php
to work
incorrectly under PHP 5.2.9 closing the connection after the token is sent (and
not waiting for the
message)
Changing these lines to the following;
$deviceToken = trim(socket_read($clientSocket, 1024));
$message = trim(socket_read($clientSocket, 1024));
Omitting the PHP_NORMAL_READ appears to have corrected this
Original issue reported on code.google.com by [email protected]
on 24 Jun 2009 at 10:13
What steps will reproduce the problem?
1. Send a successful push notification
2. Far end closes socket or socket becomes unusable
3. Try to send another Push notification and fwrite to the socket fails
What is the expected output? What do you see instead?
The fwrite error needs to be caught and a retry on another socket attempted..
What version of the product are you using? On what operating system?
Centos 5.3
Please provide any additional information below.
We were noticing the service hanging.
We solved this partly by adding the following to catch the socket fwrite
error in PushService.php. This now catches 75% of the hangs - there is
still another hang out there which we havent solved yet - we suspect
SendNotification is waiting for ever for a response to the fwrite:-
//Catch fwrite error in SendNotification
function sendNotification($deviceToken, $message)
{
//added catch fwrite error
$apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '',
$deviceToken)) . chr(0) . chr(strlen($message)) . $message;
$fwritten=fwrite($this->apnsConnection, $apnsMessage);
if ($fwritten==0 || $fwritten===FALSE || $fwritten < strlen($apnsMessage))
{
error_log(date('Y-m-d H:i')." - fwrite failed:\n".$message."\nTo device:
".$deviceToken."\n return = ".$fwritten."\n", 3, 'PushServiceError.log');
return -1;
}
return $fwritten;
}
//Spot the send failure in listenForClients()
function listenForClients()
{
$this->serviceConnection = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($this->serviceConnection, $this->serviceHost,
$this->servicePort);
socket_listen($this->serviceConnection, 10);
echo 'LISTENING ',$this->servicePort,"\n";
while($clientSocket = socket_accept($this->serviceConnection))
{
socket_write($clientSocket, "OK\n");
$deviceToken = trim(socket_read($clientSocket, 1024, PHP_NORMAL_READ));
$message = trim(socket_read($clientSocket, 1024, PHP_NORMAL_READ));
if(!empty($deviceToken) && !empty($message))
{
//SB added catch fwrite error
if ($this->sendNotification($deviceToken, $message) >= 0)
{
socket_write($clientSocket, "SENT\n");
}
else
{
socket_write($clientSocket, "ERROR\n");
}
}
else
{
socket_write($clientSocket, "ERROR\n");
}
socket_close($clientSocket);
}
}
Original issue reported on code.google.com by [email protected]
on 20 Oct 2009 at 8:49
We are having a lot of trouble in getting this to work for our iphone app - we
wanted to see if
someone wants a small cash bounty to help us to get it working on our server?
please contact [email protected] if you are able / interested in some quick $ in
helping us to
implement!
thanks
Original issue reported on code.google.com by [email protected]
on 30 Jun 2009 at 12:57
PushMonitor will consume up to whatever "memory_limit" is set to in php.ini and
then become unresponsive and need a restart. The reason for this is the call to
create_function() in the loop on line 89 of PushMonitor.php. I added the
equivalent function to the code and the memory leak went away.
Seams like this is expected with create_function()
https://bugs.php.net/bug.php?id=6333
"[2000-09-07 11:43 UTC] [email protected]
This isn't a bug but how it works. Each create_function() call creates a new
unique function. So obviously if you define zillions in an infinite loop you'll
run out of memory."
Thank you so much for making this code available. It works extremely well. I'm
able to send an average of 1.5 million push notifications a day on very modest
hardware.
Thanks,
Darren
Original issue reported on code.google.com by [email protected]
on 21 Aug 2011 at 4:49
The following PHP packages seem to also be required and they don't
necessarily install be default on all systems:
1) php-openssl
2) php-sockets
I think they should be added to the "Requirements" section of the README file
Original issue reported on code.google.com by [email protected]
on 3 Nov 2009 at 3:19
In the readme it says "To send messages, just add them to the queue!"
What does this mean??? What php do we include and a code snippet would be
handy. I can't see any function like add to queue in any of the code :-(
Original issue reported on code.google.com by [email protected]
on 23 Jun 2009 at 9:09
Hi, I know it's not really a problem with php-apns but I am having trouble
getting the script to
start automatically when my server boots.
If I enter the startup commands manually everything works as it should.
I've tried creating an init.d script but it does not work.
Which user should be starting memcache & pushmonitor.php? Should they both be
root?
Do they need to be called after apache starts?
A tutorial on how to accomplish this would be greatly appreciated.
I'm on the latest version of ubuntu on slicehost.
Thanks,
Jim
Original issue reported on code.google.com by [email protected]
on 27 Jul 2009 at 11:45
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.