Hi Everyone,
I'm using grpc in combination with rx observables and now I'm running into
an issue where I sometimes get the following exception:
System.InvalidOperationException
Message=Only one write can be pending at a time
at Grpc.Core.Internal.AsyncCallServer`2.CheckSendAllowedOrEarlyResult()
I've been searching for what this means and how to resolve this and came
across a
stack overflow post that mentions that there can be only one in-flight
message at any one time. However, I think I did that with my implementation:
public override Task MachineStatusStream(
StatusStreamRequest request,
grpc.IServerStreamWriter<StatusStreamResponse> responseStream,
grpc.ServerCallContext context)
{
return _alarmPresenter.AlarmStatusStream()
.Select(status => status.ToGrpc())
.Select(status => new StatusStreamResponse { Status = status })
.ForEachAsync(response =>
responseStream.WriteAsync(response).Wait(context.CancellationToken));
}
Isn't the `.Wait()` in the write async enough to guarantee that the write is finished?
Any pointers or help would be highly appreciated!
Best regards,
Tom