php - GearmanClient::do(): send_packet(GEARMAN_COULD_NOT_CONNECT) 在 php shell_exec 中失败

标签 php centos shell-exec gearman

我正在尝试从 php shell_exec 运行 gearman 客户端,但它总是抛出以下错误 GearmanClient::do(): send_packet(GEARMAN_COULD_NOT_CONNECT) Failed to send server-options packet -> libgearman/connection.cc:485 in/var/www/html/client.php

但是如果我从终端运行它然后它工作但不是从 php shell_exec。即使我在 addServer 方法中传递了服务器名称和端口

我在 centos 6.2 上运行。

客户端.php

       $client= new GearmanClient();  
       $client->addServer('127.0.0.1',4730);
       print $client->do("reverse","Testing");

worker.php

      $worker= new GearmanWorker();
      $worker->addServer("127.0.0.1",4730);
      $worker->addFunction("reverse", "my_reverse_function");
      function my_reverse_function($job)
      {
        return strrev($job->workload());
      }

最佳答案

确保安装了 gearman 包。或者在需要时手动安装。有时升级您的系统可能会导致您的包丢失。

然后按照此处所述在 Debug模式下检查或启动它 http://gearman.org/getting-started/

gearmand -vvv

然后启动它在后台运行

gearmand -d

我阅读了其他针对此事的问题,这些问题从

$woker->addServer('127.0.0.1',4730);

$worker->addServer('127.0.0.1:4730');

对于 $client->addServer('127.0.0.1',4730); 也是如此

关于php - GearmanClient::do(): send_packet(GEARMAN_COULD_NOT_CONNECT) 在 php shell_exec 中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23286516/

相关文章:

php - 如何创建基于两个 sql 查询的分页? (PHP)

php - JQuery 为使用 HTML5 localStorage 存储的身份验证 token 添加过期功能?

php - Mysqli 和使用 session 用户 ID 登录

linux - Freeswitch 在 centos 7.1 上启动时在 check_ip 上暂停

linux - 在 CentOS 7 上无法从 Docker 容器内访问网络

php - 无法使用PHP的shell_exec执行powershell脚本功能

java - 无法使用 PHP 将行从 Android 插入到 MySQL

Centos 磁盘 LVM 扩展

使用 gpg 命令拒绝 Php shell_exec() 权限

php - 从 PHP 运行 Linux 命令