Description
I use a blocking sub for a method that returns a stream of messages. The return type of it is Iterator<T>
. It turns out I cannot make grpc client to end the request (e.g. because of client failure). There are a number of cases where an open connection may stuck in client because of that
The implementation uses
io.grpc.stub.ClientCalls#blockingServerStreamingCall(io.grpc.Channel, io.grpc.MethodDescriptor<ReqT,RespT>, io.grpc.CallOptions, ReqT)
call, which in turn uses BlockingResponseStream
. There is no way to reach the io.grpc.ClientCall#cancel
method form the Iterator. Could be nice to wrap an Iterator or make it implement an interface in the similar way as done with ServerStreamObserver/ClientStreamObserver
The other approach could be to implement AutoCloseable
from Java with this iterator
There is also a comment on the Iterator implementation class
// TODO(ejona86): determine how to allow ClientCall.cancel() in case of application error.