Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grpc client's close function does not close data stream #1641

Open
Boronyak opened this issue Aug 1, 2022 · 0 comments
Open

Grpc client's close function does not close data stream #1641

Boronyak opened this issue Aug 1, 2022 · 0 comments

Comments

@Boronyak
Copy link

Boronyak commented Aug 1, 2022

Hi!

First I give you some details about my projects. I use Akka Streams and Akka Grpc to implement a data stream functionality. My code is written in Java. I have two main directions of streaming: receive data bytes from an interface (CAN, Ethernet etc.) -> convert it and create a message -> send it to the grpc server and receive messages from grpc server -> convert it and create data bytes -> send it to a device (CAN, Ethernet etc.).

Both data stream work fine and finally I wanted to give an extra function to close the connection with the grpc server properly (not with a for example Ctrl+C keyboard interrupt). Now I use two functions: SomeGrpcClient.close() and ActorSystem.terminate(). After close function I am waiting for the channel to be closed with the CompletableFuture.join() function. Every time it will be successfully closed and the join function immediately returns and then the program terminates the whole actor system.

This approach does not work with the first stream direction (receiving from an interface) but works fine with the second (receiving from grpc server) which I do not understand. In the first I use an infinite Source to listen to the interface and as I understand the grpc Source in the second is also an infinite Source. I expected a stream cancellation when using the grpc close function but after that it also continues sending messages to the server and when I terminate the actor system I get an exception on the client side:
GraphStage [akka.grpc.internal.AkkaNettyGrpcClientGraphStage$$anon$1] terminated abruptly, caused by for example materializer or actor system termination
and get an error like this on the server side:
ERROR a.g.j.GrpcExceptionHandler(akka://ActorSystem) - Unhandled error: [The connection closed with error: Connection reset]
akka.stream.StreamTcpException: The connection closed with error: Connection reset

I wrote this issue because I did not find a single one about this problem. Issue #212 is similar but it has been closed with the usage of shutdownNow function at version 0.2 and now I am using the 1.0.2 version. Tried with the latest also but the result is the same. My question is that this behaviour is normal and expected and the only working solution is to terminate the infinite Source with the for example Source.take() function?

Regards,

Boronyak

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant