So, ive got a simple gearman system running right now, with a worker running.
The worker basically just takes the payload (a random number in this case, and is supposed to echo it back to the screen. Literally an echo
, not returning to the client.
The client sends the random number. Im trying to do a $client->doBackground( 'post', 65482, md5(uniqid()));
but its coming back with a 47 error (GEARMAN_TIMEOUT
) every time.
getErrNo()
returns 0, error()
returns something about GEARMAN_TIMEOUT
However, when i change it to just $client->do(blah, blah, blah)
, it works just fine.
I've even occasionally seen it where the worker still echo's the number, even after getting the timeout error...
public function execute()
{
$method = 'do';
if( !$this->getBlock() )
{
$method .= ( $this->getPriority() == 'Normal' ? '' : $this->getPriority() ) . 'Background';
}
else
{
$method .= $this->getPriority();
}
echo "Method: $method \t Worker: {$this->getName()} \t Payload: {$this->getPayload()} \t Hash: {$this->getHash()}\n";
$this->setResult(
$this->getClient()
->$method(
$this->getName(),
$this->getPayload(),
$this->getHash()
)
);
if( $this->getClient()->returnCode() != GEARMAN_SUCCESS )
{
echo "Code: " . $this->getClient()->returnCode() . "\t" . GEARMAN_TIMEOUT . "\n";
}
}
that echo comes back with
Method: doHighBackground Worker: leadposter Payload: 10930 Hash: 091878f5965e4a1de2992c607b3c562b240792a6
Heres the error info
["error":"Uecode\GearmanBundle\Gearman\Job":private]=>
array(4) {
["attempts"]=>
int(3)
["return_code"]=>
int(47)
["error_no"]=>
int(0)
["error"]=>
string(103) "gearman_wait(GEARMAN_TIMEOUT) timeout reached, no servers were available -> libgearman/universal.cc:325"
}
Solved it.
Connections werent persisting across methods... so, build a server pool, and connected to the servers just before running the job