If the server is cancelling the RPC, you can call the observer like I showed above.
If the client is cancelling the RPC, it depends which API you use.
* If you are using the blocking API, you can use Context to wrap an RPC call. Another thread can cancel that context which should terminate the RPC.
* If you are using the Future API, you can call cancel(false) on the future.
* If you are using the Async API, you can call the requestObserver.onError(Status.CANCELLED.asRuntimeException()), just like you could on the server.
The client side gRPC library will end the stream and send a RST_STREAM (implementation detail) to the server. The server will either notice the cancellation via its own request observer, or by checking the Context.
Hope that helps!