I am writing a Python (version: 3.6.8) gRPC client to connect to envoy using SSL.
I am using grpc.ssl_channel_credentials to specify root_certificates, private_key and certificate_chain, and then injecting it in grpc_secure_channel call.
Also, we have alpn_protocol defined at "h2,http/1.1"
However, on running the client notice below error:
grpc._channel._InactiveRpcError: <_InactiveRRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "failed to connect to all addresses; last error: UNKNOWN : Cannot check peer: missing selected ALPN prroperty."
debug_error_string = "UNKNOWN:Failed to pick subchannel ..."
ChatGPT response when asked about error:
The "Cannot check peer: missing selected ALPN property" error message that you're seeing is related to gRPC's use of the Application-Layer Protocol Negotiation (ALPN) extension to negotiate the protocol to be used for a secure connection (e.g. HTTP/2 or HTTP/1.1).
This error typically occurs when the gRPC client is not able to negotiate the correct protocol with the server, either because the client and server do not support the same protocols, or because the client is not properly configured to use ALPN.
There are a few possible solutions to this issue:
- Make sure that the gRPC client and server support the same protocols. For example, if the server only supports HTTP/2, the client must also support HTTP/2.
- Make sure that the client is properly configured to use ALPN. This can typically be done by installing the OpenSSL library and making sure that the grpc._cython.cygrpc package is using it.
- If the error message still persist and you are using python version 3.8 and above. There is a known issue with the gRPC library in python 3.8 and above, you can upgrade to python version 3.9 and above which will fix the issue.
- If the above step did not work, you can try downgrading the gRPC library version, it could be possible that the version you are using is not compatible with the python version you are using
- If you are behind a proxy server, you may need to configure your client to use a proxy.
These are some of the common solutions, it's best to check the library and python version you are using and try to find the solution accordingly.