gearman gives me GEARMAN_COULD_NOT_CONNECT, it is definitely running

前端 未结 4 703
甜味超标
甜味超标 2020-12-18 00:15

My dev server is Debian Squeeze and I\'m running Gearman 1.1.5 which I compiled from source along with the php pecl extension v1.1.1

If I run the reverse_client.php

相关标签:
4条回答
  • 2020-12-18 00:58

    In my case it's little different. I got this same error when I had my addServer code inside the loop.

    $client = new GearmanClient();
    for ($i=0; $i<100000; $i++) {
      $client->addServer("127.0.0.1", 4730);
      $data = json_encode(array('job_id' => $i, 'task_name' => 'send-email'));
      $client->addTaskBackground('sendEmail', $data);
    }
    $client->runTasks();
    

    And this fixed it for me:

    $client = new GearmanClient();
    $client->addServer("127.0.0.1", 4730);
    for ($i=0; $i<100000; $i++) {
      $data = json_encode(array('job_id' => $i, 'task_name' => 'send-email'));
      $client->addTaskBackground('sendEmail', $data);
    }
    $client->runTasks();
    
    0 讨论(0)
  • 2020-12-18 01:06

    In case if you have used something like this

    $client->addServers('127.0.0.1', 4730);

    or

    $client->addServers();

    use something like this

    $client->addServers('127.0.0.1:4730');

    PS - I have used localhost IP, this can be replaced with actual host IP.

    0 讨论(0)
  • 2020-12-18 01:07

    I had the same problem and recently solved them after a couple days of frustration (hard to troubleshoot since there are three processes to worry about :-)

    It appears (at least in my case) that the PHP documentation for GearmanClient::addServer() and GearmanWorker::addServer() is incorrect. Specifically, the docs seem to imply that hostname and port number are optional and that it will use localhost and port 4730 as defaults if you do not specify them. This never works - it suddenly occurred to me today to try explicitly specifying them for both client and worker processes and everything started working.

    Try specifying all values for hostnames and ports and see if this works for you.

    0 讨论(0)
  • 2020-12-18 01:08

    May be this could help someone. If you want to use single server, you can use

    $client->addServer($host, $port)
    e.g. $client->addServer('127.0.0.1', 4730)
    

    http://php.net/manual/en/gearmanclient.addserver.php

    If you want to use multiple server, then you can use

    $client->addServers($host1:$port1, $host2:$port2, $host3:$port3)
    e.g. $client->addServers('127.0.0.1:4730', '127.0.0.2:8080')
    

    http://php.net/manual/en/gearmanclient.addservers.php

    0 讨论(0)
提交回复
热议问题