The problem of using grpc in PHP

recently, while learning grpc, I found that V2ray"s API was written in grpc, so I gave it a try. Encountered the following problems

  1. when a reply is received after the message is sent, php throws fatalerror
<?php
require_once __DIR__ . "/vendor/autoload.php";
try {
    $client = new V2ray\Core\App\Stats\Command\StatsServiceClient("1.1.1.1:8080", [
        "credentials" => Grpc\ChannelCredentials::createInsecure(),
    ]);
    $request = new V2ray\Core\App\Stats\Command\GetStatsRequest();
    $request->setName("user>>>10000@aaa.net>>>traffic>>>downlink");
    $obj = $client->GetStats($request);
   $obj2 =  $obj->wait();
    var_dump($obj2);
}catch (Throwable $e){
  echo   $e->getMessage();
  var_dump($e->getTrace());
}
?>
output
string(46) "\V2ray\Core\App\Stats\Command\GetStatsResponse"
bool(true)
PHP Fatal error:  Cannot access private properties. in /Users/v2ray/vendor/grpc/grpc/src/lib/AbstractCall.php on line 147

Fatal error: Cannot access private properties. in /Users/v2ray/vendor/grpc/grpc/src/lib/AbstractCall.php on line 147
  1. Endpoint debugging found the problem file / Users/v2ray/vendor/grpc/grpc/src/lib/AbstractCall.php error location is the _ deserializeResponse () method near line 134
protected function _deserializeResponse($value)
    {
        if ($value === null) {
            return;
        }
//        var_dump("fsdfasdfsdfsdf");
//        var_dump($this->deserialize);
        // Proto3 implementation
        if (is_array($this->deserialize)) {
            list($className, $deserializeFunc) = $this->deserialize;
            var_dump($className);
            var_dump(class_exists($className));
            $obj = new $className();
            var_dump($obj); //
            var_dump("");
            var_dump(get_class_methods($obj, $deserializeFunc));
//            exit;
//            sleep(2);
            if (method_exists($obj, $deserializeFunc)) {
                $obj->$deserializeFunc($value);
            } else {
                $obj->mergeFromString($value);
            }

            return $obj;
        }

        // Protobuf-PHP implementation
        return call_user_func($this->deserialize, $value);
    }
output:
string(46) "\V2ray\Core\App\Stats\Command\GetStatsResponse"
bool(true)
PHP Fatal error:  Cannot access private properties. in /Users/hainuo/Downloads/Shadowsocks/vendor/grpc/grpc/src/lib/AbstractCall.php on line 147

Fatal error: Cannot access private properties. in /Users/hainuo/Downloads/Shadowsocks/vendor/grpc/grpc/src/lib/AbstractCall.php on line 147
    

found that a class generated by protoc made an error when called after a new operation.

/**
 * Generated from protobuf message v2ray.core.app.stats.command.GetStatsResponse
 */
class GetStatsResponse extends \Google\Protobuf\Internal\Message

you can see here that it inherits protobuf"s message class.
I really can"t find any errors. Please help me with your opinions on how to debug and how to solve this problem

.

the environment is as follows

Installed packages, channel pecl.php.net:
=========================================
Package  Version State
grpc     1.12.0  stable
protobuf 3.6.0   stable
swoole   2.1.3   stable
Mar.25,2021

the content contained in this class is private when the reason has been solved, so a direct call will report an error


how are you doing with v2ray's php grpc

Menu