1

I am trying to implement server-side streaming rpc to send messages from server to client.

rpc CheckSystem(CheckSystemRequest) returns (stream CheckSystemResponse) {}

Server code:

public override Task CheckSystem(CheckSystemRequest request, IServerStreamWriter<CheckSystemResponse> responseStream, ServerCallContext context) {
  return Task.Run(async () => {
    for(int i = 1; i <= 10; i++) { 
      await responseStream.WriteAsync(new CheckSystemResponse { Type = i.ToString() });
      Console.WriteLine($"{DateTime.Now}: Sent {i}");
      Thread.Sleep(10000);
    }
  });
}

Client code:

public static async Task TestAsync() {
  try {        
    using (var call = client.CheckSystem(new CheckSystemRequest { Code = "1" })) {
      var responseStream = call.ResponseStream;
      while (await responseStream.MoveNext()) {
        var current = responseStream.Current;
        Console.WriteLine($"{DateTime.Now}: Received: Type = {current.Type}");
      }
    }
  }
  catch (Exception ex) {
    Console.WriteLine(ex.Message);
  }
}

After starting, I see that on the server side a message is sent every 10 seconds. Screenshot #1.

13.12.2019 **16:31:31**: Sent 1
13.12.2019 **16:31:41**: Sent 2
13.12.2019 16:31:51: Sent 3
13.12.2019 16:32:01: Sent 4
13.12.2019 16:32:11: Sent 5
13.12.2019 16:32:21: Sent 6
13.12.2019 16:32:31: Sent 7
13.12.2019 16:32:41: Sent 8
13.12.2019 16:32:51: Sent 9
13.12.2019 16:33:01: Sent 10

But, the client begins to process the first message only after the server sends the second. Screenshot #2

13.12.2019 **16:31:41**: Received: Type = 1
13.12.2019 **16:31:41**: Received: Type = 2
13.12.2019 16:31:51: Received: Type = 3
13.12.2019 16:32:01: Received: Type = 4
13.12.2019 16:32:11: Received: Type = 5
13.12.2019 16:32:21: Received: Type = 6
13.12.2019 16:32:31: Received: Type = 7
13.12.2019 16:32:41: Received: Type = 8
13.12.2019 16:32:51: Received: Type = 9
13.12.2019 16:33:01: Received: Type = 10

What could be the reason for this behavior? And how can this be fixed?

LPLN
  • 475
  • 1
  • 6
  • 20
SLavaLL
  • 31
  • 3
  • 1
    Have you resolved the problem? We are experiencing the same issue now with C# client. – ysakiyev Sep 14 '20 at 12:33
  • 1
    This problem was reproduced only on computers with Windows 7. I Think, since Windows 7 is removed from support, no one will solve this problem. You can view it at this [link](https://github.com/grpc/grpc/issues/21484) – SLavaLL Sep 15 '20 at 08:28
  • It reproduced here on Windows 10 – ysakiyev Sep 17 '20 at 04:22

0 Answers0