skip to Main Content

I cannot use the container image name (ex: ‘dns://container-name:50051’), but only the ip adress of the container.

I am using a php client to call a grpc microservice.

When i try to connect using the container image name i have that following error message
Failed to create secure client channel

Any idea?

2

Answers


  1. Chosen as BEST ANSWER
    public function Healthcheck(): HealthcheckResponse|false
    {
        $url = 'dns://server-grpc'; // doesn't work
        $url = '172.18.0.99:50051'; // works
        
    
        $client = new TestClient($url, [
            'credentials' => ChannelCredentials::createInsecure(),
        ]);
    
        $request = new HealthcheckRequest();
    
        list($reply, $status) = $client->Healthcheck($request)->wait();
    
        if(! $this->errorsHandler($status, $reply)) {
            return false;
        }
    
        return $reply;
    }
    

  2. services:
        client:
            extra_hosts:
                - server-grpc:172.18.0.99
    ...
    

    That is my docker compose

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search