Skip to content

Commit 8cab08b

Browse files
authored
Apply the grpcMaxMessageLength setting received from the host to configure the gRPC channel (#346)
1 parent 3e8589d commit 8cab08b

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/Messaging/MessagingStream.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@ internal class MessagingStream
1717
private readonly AsyncDuplexStreamingCall<StreamingMessage, StreamingMessage> _call;
1818
private readonly SemaphoreSlim _semaphoreSlim = new SemaphoreSlim(initialCount: 1, maxCount: 1);
1919

20-
internal MessagingStream(string host, int port)
20+
internal MessagingStream(string host, int port, int maxMessageLength)
2121
{
22-
Channel channel = new Channel(host, port, ChannelCredentials.Insecure);
22+
var channelOptions = new []
23+
{
24+
new ChannelOption(ChannelOptions.MaxReceiveMessageLength, maxMessageLength),
25+
new ChannelOption(ChannelOptions.MaxSendMessageLength, maxMessageLength)
26+
};
27+
28+
Channel channel = new Channel(host, port, ChannelCredentials.Insecure, channelOptions);
2329
_call = new FunctionRpc.FunctionRpcClient(channel).EventStream();
2430
}
2531

src/Worker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public async static Task Main(string[] args)
3535
.WithParsed(ops => arguments = ops)
3636
.WithNotParsed(err => Environment.Exit(1));
3737

38-
var msgStream = new MessagingStream(arguments.Host, arguments.Port);
38+
var msgStream = new MessagingStream(arguments.Host, arguments.Port, arguments.MaxMessageLength);
3939
var requestProcessor = new RequestProcessor(msgStream);
4040

4141
// Send StartStream message

0 commit comments

Comments
 (0)