How to increase message size in grpc using python

前端 未结 3 1625
死守一世寂寞
死守一世寂寞 2021-01-04 10:30

I am using grpc for message passing and am testing a simple server and client. When my message size goes over the limit, I get this error.

grpc._channel._R         


        
相关标签:
3条回答
  • 2021-01-04 11:03

    Changing the message_length for both send and receive will do the trick.

    channel = grpc.insecure_channel(
        'localhost:50051',
        options=[
            ('grpc.max_send_message_length', MAX_MESSAGE_LENGTH),
            ('grpc.max_receive_message_length', MAX_MESSAGE_LENGTH),
        ],
    )
    
    0 讨论(0)
  • 2021-01-04 11:04

    I had this problem, I solved it by setting the 'grpc.max_send_message_length' and 'grpc.max_receive_message_length' on both the client and the server:

    In client (Credit to @Dumbo for this code snippet):

    channel = grpc.insecure_channel(
        'localhost:50051',
        options=[
            ('grpc.max_send_message_length', MAX_MESSAGE_LENGTH),
            ('grpc.max_receive_message_length', MAX_MESSAGE_LENGTH),
        ],
    )
    

    In server:

    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10), options = [
            ('grpc.max_send_message_length', MAX_MESSAGE_LENGTH),
            ('grpc.max_receive_message_length', MAX_MESSAGE_LENGTH)
        ])
    
    0 讨论(0)
  • 2021-01-04 11:06

    You should not increase the message size.
    It comes with a performance penalty.
    In real situations one implements paging to split too large messages.

    0 讨论(0)
提交回复
热议问题