I’m trying to run the example Gearman worker from their documentation (see below), but every time I do I get a slew of errors in my Gearman log file like this: FATAL [ 0] gearman_packet_unpack_header:invalid command value. When I run the Gearman client (again, their own example), it doesn’t seem to change anything. Nothing happens.
Here is the sample worker code that is failing
# Create our worker object.
$worker= new GearmanWorker();
# Add default server (localhost).
$worker->addServer();
# Register function "reverse" with the server.
$worker->addFunction("reverse", "reverse_fn");
while (1)
{
print "Waiting for job...\n";
$ret= $worker->work();
if ($worker->returnCode() != GEARMAN_SUCCESS)
break;
}
# A much simple reverse function
function reverse_fn($job)
{
$workload= $job->workload();
echo "Received job: " . $job->handle() . "\n";
echo "Workload: $workload\n";
$result= strrev($workload);
echo "Result: $result\n";
return $result;
}
>php -i:
extension version 1.0.2
libgearman version 0.29
Default TCP Host localhost
Default TCP Port 4730
>gearmand -V:
gearmand 0.29
How do I correctly configure Gearman to work? libgearman is the same version as gearmand, and my PECL extension is the most-recent stable version. I’m not sure what else to try.
As far as I was able to tell, the PECL extension for Gearman as version 1.0.2 does not work with Gearman version 0.29. I updated Gearman and libgearman both to version 0.33, and as soon as I did my extension was working.