GearmanWorker因“无法设置例外选项”而失败

时间:2015-02-07 15:18:14

标签: php gearman

我正在尝试使用德语构建分布式处理环境,但我在第一步就失败了。我的设置: PHP 5.6.4-1~dotdeb.1 gearman support => enabled libgearman version => 1.1.12 gearman-server-0.6.2.jar

样本工作者

<?php
$worker= new GearmanWorker();
echo "worker options: " . $worker->options() . PHP_EOL;
$worker->setOptions(1);
echo "worker options: " . $worker->options() . PHP_EOL;
$worker->addServer("192.168.130.16");
$worker->addFunction("reverse", "my_reverse_function");
while ($worker->work());

function my_reverse_function($job)
{
  return strrev($job->workload());
}
?>

尝试运行worker时出现错误:

vagrant@planq:~$ php worker.php 
PHP Fatal error:  Uncaught exception 'GearmanException' with message 'Failed to set exception option' in /home/vagrant/worker.php:3
Stack trace:
#0 /home/vagrant/worker.php(3): GearmanWorker->addServer('192.168.130.16', 4730)
#1 {main}
  thrown in /home/vagrant/worker.php on line 3

和服务器报告

10:15:02.762 - [nioEventLoopGroup-3-2] DEBUG n.j.gearman.server.net.PacketHandler - Creating new handler!
10:15:02.762 - [nioEventLoopGroup-3-2] ERROR n.j.g.common.packets.PacketFactory - Unhandled type: 
10:15:02.763 - [nioEventLoopGroup-3-2] WARN  n.j.gearman.server.net.PacketHandler - Unexpected exception from downstream.
io.netty.handler.codec.DecoderException: java.lang.NullPointerException
    at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:415) ~[gearman-server-0.8.9-20141210.162656-1.jar:0.4]
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:131) ~[gearman-server-0.8.9-20141210.162656-1.jar:0.4]
    at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:334) [gearman-server-0.8.9-20141210.162656-1.jar:0.4]
    at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:320) [gearman-server-0.8.9-20141210.162656-1.jar:0.4]
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [gearman-server-0.8.9-20141210.162656-1.jar:0.4]
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:100) [gearman-server-0.8.9-20141210.162656-1.jar:0.4]
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:497) [gearman-server-0.8.9-20141210.162656-1.jar:0.4]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:465) [gearman-server-0.8.9-20141210.162656-1.jar:0.4]
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:359) [gearman-server-0.8.9-20141210.162656-1.jar:0.4]
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) [gearman-server-0.8.9-20141210.162656-1.jar:0.4]
    at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
Caused by: java.lang.NullPointerException: null
    at net.johnewart.gearman.server.net.Decoder.decode(Decoder.java:60) ~[gearman-server-0.8.9-20141210.162656-1.jar:0.4]
    at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:360) ~[gearman-server-0.8.9-20141210.162656-1.jar:0.4]
    ... 10 common frames omitted
10:15:02.764 - [nioEventLoopGroup-3-2] DEBUG n.j.gearman.server.net.PacketHandler - Client closed channel: [id: 0x89bba760, /192.168.130.16:59106 :> 0.0.0.0/0.0.0.0:4730]
10:15:03.637 - [pool-2-thread-1] DEBUG n.j.g.s.u.SnapshottingJobQueueMonitor - Snapshotting job queues.
10:15:03.638 - [pool-2-thread-1] DEBUG n.j.g.s.u.SnapshottingJobQueueMonitor - Condensing data points

我会对解决问题的任何线索有帮助......

2 个答案:

答案 0 :(得分:0)

原来这是服务器中的一个错误。提交后,bug report John修复了服务器。版本0.8.10-SNAPSHOT
解决问题,并像魅力一样工作。

答案 1 :(得分:0)

在大多数情况下(但不是您的情况),它仅表示Gearman服务器不可连接。或默认情况下绑定到localhost。检查/etc/default/gearman-job-server以及两者之间的所有防火墙。