Clarifai返回握手错误当使用GRPC Python客户机



我尝试使用澄清-python-grpc客户端,它工作得很好。这里我只是想尝试人口统计模型进行测试。它在2周前工作,但我认为是grpc的更新导致了这个错误。

from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc import api
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_pb2, status_code_pb2
channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)
api_key = 'sanitized'
metadata = (('authorization', f'Key {api_key}'),)
post_model_outputs_response = stub.PostModelOutputs(
service_pb2.PostModelOutputsRequest(
model_id="c0c0ac362b03416da06ab3fa36fb58e3",#demographics_model  
inputs=[
resources_pb2.Input(
data=resources_pb2.Data(
image=resources_pb2.Image(
url="https://samples.clarifai.com/metro-north.jpg"
)
)
)
],
model=resources_pb2.Model(
output_info=resources_pb2.OutputInfo(
output_config=resources_pb2.OutputConfig(
select_concepts=[
# When selecting concepts, value is ignored, so no need to specify it.
resources_pb2.Concept(name="train"),
resources_pb2.Concept(id="ai_6kTjGfF6")
]
)
)
)
),
metadata=metadata
)
if post_model_outputs_response.status.code != status_code_pb2.SUCCESS:
raise Exception("Post model outputs failed, status: " + post_model_outputs_response.status.description)
# Since we have one input, one output will exist here.
output = post_model_outputs_response.outputs[0]
print("Predicted concepts:")
for concept in output.data.concepts:
print("%s %.2f" % (concept.name, concept.value))

今天我尝试了相同的脚本,我得到这个错误:

E1004 14:07:49.389861000 8636689920 ssl_transport_security.cc:1469]    Handshake failed with fatal error SSL_ERROR_SSL: error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED.
E1004 14:07:49.629743000 8636689920 ssl_transport_security.cc:1469]    Handshake failed with fatal error SSL_ERROR_SSL: error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED.
E1004 14:07:49.851189000 8636689920 ssl_transport_security.cc:1469]    Handshake failed with fatal error SSL_ERROR_SSL: error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED.
Traceback (most recent call last):
File "/Users/Test_Pys/211003_test.py", line 40, in <module>
post_model_outputs_response = stub.PostModelOutputs(
File "/Users/opt/anaconda3/envs/testing/lib/python3.9/site-packages/grpc/_channel.py", line 946, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "/Users/opt/anaconda3/envs/testing/lib/python3.9/site-packages/grpc/_channel.py", line 849, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "failed to connect to all addresses"
debug_error_string = "{"created":"@1633349269.851731000","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":3159,"referenced_errors":[{"created":"@1633349269.851729000","description":"failed to connect to all addresses","file":"src/core/lib/transport/error_utils.cc","file_line":147,"grpc_status":14}]}"

我能做些什么来解决这个问题?

删除SHA1指纹:da:c9:02:4f:54:d8:f6:df:94:93:5f:b1:73:26:38:ca:6a:d7:7c:13根证书。Pem文件为我解决了这个问题

gRPC Core的新版本1.41.1修复了它https://github.com/grpc/grpc/pull/27539

最新更新