Search code examples
phpapachegrpc

PHP gRPC ignores keepalive parameters


I put these 3 parameters:

grpc.keepalive_time_ms=7200000
grpc.keepalive_timeout_ms=200000
grpc.keepalive_permit_without_calls=1

in /etc/php/8.1/apache2/conf.d/20-grpc.ini, /etc/php/8.1/apache2/conf.d/custom-php.ini, /etc/php/8.1/cli/conf.d/20-grpc.ini and /etc/php/8.1/cli/conf.d/custom-php.ini. Then I restart webserver (whole Docker container) and list grpc config with php -i | grep grpc and they are missing from the output:

/etc/php/8.1/cli/conf.d/20-grpc.ini,
grpc
grpc support => enabled
grpc module version => 1.59.1
grpc.enable_fork_support => 0 => 0
grpc.grpc_trace => all,-timer_check => all,-timer_check
grpc.grpc_verbosity => debug => debug
grpc.log_filename => /var/log/grpc.log => /var/log/grpc.log
grpc.poll_strategy => no value => no value

I tested it with PHP 8.1, gRPC extension 1.45.0 and 1.59.1. What am I doing wrong?


Solution

  • It turns out these parameters dont belong to PHP .ini config files. They need to be in PHP code, passed as options array into gRPC client class constructor.

    $options['grpc.keepalive_time_ms'] = 7200000;
    $options['grpc.keepalive_timeout_ms'] = 200000;    
    $options['grpc.keepalive_permit_without_calls'] = 1;
    
    $client = new Client('host:port', $options);