Thanks. In 1.0.0 version, the max message size is 4MiB, prior version is
100MiB.
Now my solution as below:
At client side, we can provide an option max_message_length, for example.
options = [(cygrpc.ChannelArgKey.max_message_length, 100 * 1024 * 1024)]
channel = grpc.insecure_channel('localhost:10419', options)
At server side, there is no options param for server interface.
But we can modify the library, for
example: https://github.com/grpc/grpc/pull/7926 or you can extend the
Server class. I select the second solution:
from grpc._cython import cygrpc
from grpc import _server
class MyServer(_server.Server):
_state = None
def __init__(self, thread_pool, generic_handlers, args=None):
completion_queue = cygrpc.CompletionQueue()
server = cygrpc.Server(args)
server.register_completion_queue(completion_queue)
self._state = _server._ServerState(
completion_queue, server, generic_handlers, thread_pool)
在 2016年8月30日星期二 UTC+8下午12:01:27,[email protected]写道:
>
> Hi, all
>
> I wrote a server and client in Python, grpcio version is 1.0.0, protobuf
> is 3.0.0, os is centos 6.
>
> my proto file is
> -------------------------
> service AudioClassification {
> rpc Classify (AudioUnit) returns (Prob) {
> }
> }
> message AudioUnit {
> string id = 1;
> bytes audio = 2;
> }
> message Prob {
> float prob = 1;
> }
> ---------------------------
>
> when I run my client, I will put an audio file content to the field audio.
> If the file size is 841772 bytes, the return will be ok, but the file size
> is large, for example, 4482088 bytes, it will return an error, the
> stacktrace is bellow:
> ------------------------------------------------------
> File "./client2.py", line 12, in run
> reply = stub.Classify(AudioUnit(id='1',
> audio=bytes(open('../data/1018465138.wav', 'rb').read())), timeout=3600)
> File
> "/home/web_server/dlpy2/dlpy/lib/python2.7/site-packages/grpc/_channel.py",
> line 481, in __call__
> return _end_unary_response_blocking(state, False, deadline)
> File
> "/home/web_server/dlpy2/dlpy/lib/python2.7/site-packages/grpc/_channel.py",
> line 432, in _end_unary_response_blocking
> raise _Rendezvous(state, None, None, deadline)
> grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with
> (StatusCode.INTERNAL,
> {"created":"@1472528410.219728253","description":"RST_STREAM","file":"src/core/ext/transport/chttp2/transport/frame_rst_stream.c","file_line":107,"http2_error":2})>
> ------------------------------------------------------
>
> my client code is:
> ---------------
> def run():
> channel = grpc.insecure_channel('localhost:10411')
> stub = AudioClassificationStub(channel)
> reply = stub.Classify(AudioUnit(id='1',
> audio=bytes(open('../data/1018465138.wav', 'rb').read())), timeout=3600)
> print(reply.prob)
>
> if __name__ == '__main__':
> run()
> ---------------
>
> Anyone can give me some tips?
>
--
You received this message because you are subscribed to the Google Groups
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit
https://groups.google.com/d/msgid/grpc-io/e6e94fb1-59f2-4d79-9b78-071b2e2dab53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.