Yes, it is grpc-java.

How I detected this was that google-cloud-pubsub is one of our dependencies 
and I noticed that 1.114.6 works but not 1.114.7. After digging into it 
deeper, I found the grpc version was upgrade from 1.40.x to 1.41.x.

The server is written in Java and the client is written in Python. The 
server version is currently at 1.42.2. I am not sure what the client grpc 
version is. I am using Python 3.8 and protoc version is 3.6.1.

The disconnection happens in the middle of a streaming RPC and the 
cancellation is detected inside a while loop. Here is a sample code snippet:

Greeting greeting = request.getGreeting();
String firstName = greeting.getFirstName();
String lastName = greeting.getLastName();

int i = 0;

ServerCallStreamObserver<GreetResponse> serverCallStreamObserver =
(ServerCallStreamObserver<GreetResponse>)responseObserver;

try {
while (true) {
if (serverCallStreamObserver.isCancelled()) {
System.out.println("cancelled");
serverCallStreamObserver.onCompleted();
break;
}

String result = "Hello " + firstName + " " + lastName + ", response number: 
" + i;
GreetResponse response = GreetResponse.newBuilder()
.setResult(result)
.build();
responseObserver.onNext(response);

Thread.sleep(1000L);
i++;
}
} catch (InterruptedException e) {
e.printStackTrace();
}

On Thursday, 14 April 2022 at 17:21:43 UTC-4 [email protected] wrote:

> I am assuming it is grpc-java you are talking about. Couple of questions:
>
> - "when gRPC version is higher than 1.41.x" : can you pinpoint whether the 
> client version or the server version causes this changed behavior?
> - "...cannot detect disconnection of a client ..." do you mean that when a 
> disconnection happens in the middle of a streaming RPC the server used to 
> detect it as a cancellation and that doesn't happen anymore?
>
> Same question about "...if the client disconnects from the server,..." : 
> do you mean to say a TCP disconnection to be detected inside your while 
> loop?
>
>
>
> On Thursday, April 14, 2022 at 10:31:52 AM UTC-7 [email protected] wrote:
>
>> Hi,
>>
>> I have recently discovered serverCallStreamObserver.isCancelled() cannot 
>> detect disconnection of a client when gRPC version is higher than 1.41.x. 
>> So, the server logic that I have contains a while loop that runs forever 
>> and if the client disconnects from the server, it will call onCompleted() 
>> before breaking from the loop. I am wondering what has changed in the new 
>> versions and what is the new way to implement a similar behaviour?
>>
>> Regards,
>> Bill
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/ed361baf-1507-43e2-b09d-e930afe296f8n%40googlegroups.com.

Reply via email to