You are using foreachasync so each (multiple in parallel) will perform the 
write before the wait is hit, which is not valid. Just use foreach instead and 
drop the wait, or sync on the write. 

> On Nov 23, 2018, at 9:30 AM, [email protected] wrote:
> 
> 
> 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
> -- 
> 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/6555421c-5c63-472c-adc6-0e1e56ad48a4%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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/35FC4803-E724-457E-9B16-A743411DB8DE%40earthlink.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to