集成GRPC 客户端

eicesoft

问题描述

这里详细描述问题
我准备开放一个接口给调用Go写的GRPC. 这段代码放到Controller中直接报错, 但是我放到PHP Cli模式写跑是正常返回的. 不确定是什么原因.
而且我发现, 在Windows下 可以正常运行. 返回正确的结果, 唯一的可能就是Event-Loop:\Workerman\Events\Select 这个事件处理器导致的结果

控制器下的程序代码

 public function test()
    {
$hostname = 'localhost:2223';
$client = new \Proto\BlacklistClient($hostname, [
'credentials' => \Grpc\ChannelCredentials::createInsecure(),
]);

$request = new \Proto\MobileRequest();
$request->setMobiles([
13688889996,
13688889997,);
dump($client);
$resp = $client->WriteWhite($request)->wait();
dump($resp);
}

Cli模式下, 直接跑的代码

<?php
include 'vendor/autoload.php';

$hostname = 'localhost:2223';
$client = new \Proto\BlacklistClient($hostname, [
    'credentials' => \Grpc\ChannelCredentials::createInsecure(),
]);

$request = new \Proto\MobileRequest();
$request->setMobiles([
    13688889996,
    13688889997,]);

list($response, $status) = $client->WriteBlack($request)->wait();
if ($status->code === \Grpc\STATUS_OK) {

    dump($response);
}

报错信息

Blacklist write b:{1561883092,1561883093,15618830982,15618830983}, w:{1361883092,1361883093,13618830982,13618830983}.
^ Proto\BlacklistClient^ {#380
  -hostname: "localhost:2223"
  -hostname_override: null
  -channel: Grpc\Channel {#383}
  -call_invoker: Grpc\DefaultCallInvoker^ {#386}
  -update_metadata: null
}
[mutex.cc : 2417] RAW: Check w->waitp->cond == nullptr failed: Mutex::Fer while waiting on Condition
worker[webman:11067] exit with status 134

操作系统及workerman/webman等框架组件具体版本

这里写具体的系统环境相关信息
操作系统是Centos8, PHP版本7.4, PHP grpc扩展是1.6.2.

327 1 0
1个回答

walkor

可能是触发了php或者grpc扩展的某个bug,换个php版本试或者grpc扩展版本试下

  • eicesoft 2024-03-04

    感觉还是和eventloop那块有关系. PHP换了没用.

🔝