I am experiencing an issue where gRPC calls from PHP to a server running Python sometimes return null responses. When making the same request using HTTP, the response is successfully received. However, intermittently, the HTTP requests return null without any indication of a timeout or error. CPU, memory, and network resources are all performing well. I am using PHP-FPM 7.4 with an Nginx web server.
Here is an example code block:
public function __construct($x_site_id="1") {
$x_site_id = $this->setSiteId($x_site_id);
$this->options = $this->setOptions($x_site_id);
parent::__construct();
$this->grpc_port = config('app.FUNITY_CLT_GRPC_PORT');
$this->clt_endpoint = $this->grpc_lb . ':' . $this->grpc_port;
}
public function search($param = []) {
try {
list($reply, $status) = (new SubTopPageClient($this->clt_endpoint, $this->options))
->Search(
(new SubTopPageSearchRequest())
->setQueryList(
(function ($param) {
foreach ($param as $key => $value) {
$query_list[] = (new SubTopPageSearchQuery())
->setSearchKey($this->keymap[$key])
->{$this->valuemap[$key]}($value);
}
return $query_list ?? [];
})($param)
)
)
->wait();
return $this->messageToArray($reply);
} catch (Exception $e) {
throw new LogicException(LogConst::SYSTEM_ERROR_001, $this->context($e, __FUNCTION__));
}
}
I need assistance to understand why these gRPC calls sometimes return null and how to resolve the issue.
Trung Trần is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.