【问题标题】:Gearman client failed in webpage,but succeed in command line interface?Gearman 客户端在网页中失败,但在命令行界面中成功?
【发布时间】:2016-01-30 11:36:32
【问题描述】:

client.php 示例使用命令“php client.php”,在http://gearman.org/getting-started/ 可以成功与worker.php 通信,但是在webbrowser 中使用无法与worker.php 通信,有谁知道为什么以及如何配置gearmand 还是变通?

操作系统:CentOS 6.7 Gearmand 版本:1.1.8。 Gearmand 以“gearmand -l stderr --verbose DEBUG”开头 客户端使用“gearman -f work

调试 2015-10-30 11:56:01.371309 [1] 收到 GEARMAN_GRAB_JOB_ALL ::58ca:3fa1:77f:0%4234047483:2705334353 -> libgearman-server/thread.cc:310 调试 2015-10-30 11:56:01.371317 [1] ::58ca:3fa1:77f:0%4234047483:41704 观看 POLLIN -> libgearman-server/gearmand_thread.cc:151 调试 2015-10-30 11:56:01.371334 [proc] ::58ca:3fa1:77f:0%4234047483:41704 数据包命令 GEARMAN_CAN_DO -> libgearman-server/server.cc:111 调试 2015-10-30 11:56:01.371344 [proc] 注册功能:工作-> libgearman-server/server.cc:522 调试 2015-10-30 11:56:01.371352 [proc] ::58ca:3fa1:77f:0%4234047483:41704 数据包命令 GEARMAN_GRAB_JOB_ALL -> libgearman-server/server.cc:111 调试 2015-10-30 11:56:01.371371 [1] 收到 RUN 唤醒事件 -> libgearman-server/gearmand_thread.cc:610

但是当网络浏览器导航到“http://localhost/client.php”时,网络浏览器中没有显示任何信息,终端也没有显示任何信息。

nginx的error.log信息如下: 2015/10/30 04:59:10 [error] 2756#0: *2 FastCGI sent in stderr: "PHP message: PHP Warning: GearmanClient::doNormal(): send_packet(GEARMAN_COULD_NOT_CONNECT) 发送服务器选项包失败 - > libgearman/connection.cc:485 in /usr/share/nginx/html/client.php on line 4" 同时从上游读取响应标头,客户端:127.0.0.1,服务器:localhost,请求:“GET /client.php HTTP/1.1”,上游:“fastcgi://127.0.0.1:9000”,主机:“localhost”

[root@localhost html]# cat client.php

<?php
$client= new GearmanClient();
$client->addServer("127.0.0.1",4730);
print $client->doNormal("reverse", "Hello World!");
?>

[root@localhost html]# cat worker.php

<?php
$worker= new GearmanWorker();
$worker->addServer("127.0.0.1",4730);
$worker->addFunction("reverse", "my_reverse_function");
while ($worker->work());

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

可能问题是网页对socket操作有限制或权限?

我认为带有 --http-port 选项的配置现在可能不成熟和稳定,所以我更喜欢的解决方案是 php 网页作为客户端可以直接向 Gearmand 提交作业,由 C++ 编译的工作程序处理。并且 c++ worker 程序应该在不调用的情况下处理许多请求,并且每个请求都运行和退出以节省时间。

这个解决方案是否可行。

请帮帮我。

非常感谢!

【问题讨论】:

    标签: c++ linux sockets gearman


    【解决方案1】:

    在 tom、Wali Usmani 和 Clint 的指导下,最终将原因缩小到 SELinux 中的权限问题。

    详情可参考https://groups.google.com/forum/#!topic/gearman/_dW8SRWAonw

    非常感谢 tom、Wali Usmani 和 Clint。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-11
      • 1970-01-01
      • 1970-01-01
      • 2015-05-20
      • 2020-10-10
      相关资源
      最近更新 更多