I'm trying to send a grpc request and I'm expected to receive stream of message back. Instead I'm receiving a response as <_MultiThreadedRendezvous object>. Can anyone help me to understand why I'm receiving this and what should I do to extract the expected message from this object. The server is C++ and client is python in this case.
Please take a look at gRPC's example of streaming RPC. The _MultiThreadedRendezvous
object is the library's representation of an RPC result. It is an iterable, you can use for
to fetch all responses, or you can use list()
to get all messages.
for
loop solved this, thanks. –
Fleabag Using e.code()
and e.details()
helped me parsing it:
try:
response = stub.SayHello(...)
except _MultiThreadedRendezvous as e:
if e.code() == grpc.StatusCode.CANCELLED:
pass
# process cancelled status
elif e.code() == grpc.StatusCode.UNAVAILABLE and 'Connection reset by peer' in e.details():
pass
# process unavailable status
else:
raise
Looking at the source code of that error helped me understand how to parse it.
Credit to this answer on another question.
I've spent few hours on the same issue and i've figured out that _MultiThreadedRendezvous
returned could be because of some issue has occurred. This is not the normal behavior of grpc.
For my case, i've NOT kept the .proto
file up to date for both of my services.
I'm setting up a microservices with 2 services: grpc-service and bff-service. Both services have the same .proto
file because they need to contact to each other.
But i've changed the .proto
file of grpc-service, but not update in bff-serivce, which led to this issue. I've updated it to be the same as each other, and it's worked.
Hope this information helped someone.
© 2022 - 2024 — McMap. All rights reserved.