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

Client close doesn't kill stream on server #212

Closed
peteremiljensen opened this issue May 25, 2018 · 9 comments
Closed

Client close doesn't kill stream on server #212

peteremiljensen opened this issue May 25, 2018 · 9 comments
Assignees
Labels
bug Something isn't working client in progress
Milestone

Comments

@peteremiljensen
Copy link

I've a question. The server streams out stock quotes to a client.
But I can't seem to close the stream again. If calling client.close on the client-side, then the server stil streams quotes. It only stops if I terminate the client.

Is client.close not closing any living connections? Or am I misunderstanding something?

Thank you :)

@raboof raboof added the client label May 25, 2018
@raboof
Copy link
Member

raboof commented May 25, 2018

Hi Peter, thanks for the feedback! It is indeed correct that shutdown will do an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled.

Can you tell a bit more about your use case? Typically I'd say gRPC clients might be long-running processes, what is your reason for closing it? Are you winding down the entire application? Would you want/expect to cancel both existing and new calls to be shut down on close?

@peteremiljensen
Copy link
Author

Hi Arnout.
Thanks for the quick reply.

I my use case the client should ideally also be long-running. However, I have a variable amount of actors that get spawned at different times subscribing to multiple different quotes. And they also get torn down frequently.

But, when all the actors using a specific quote stops, I would like to be able to stop the specific quote currently streaming.
Therefore, as a last resort I tried closing everything with client.close, which makes sense to be long-living :)
Is there a way to stop particular streams end-to-end? I tried failing the stream using KillSwitches, but that didn't close the stream on the server.

I hope I'am clear. Otherwise just ask :)
Thanks

@raboof
Copy link
Member

raboof commented May 25, 2018

I think ideally terminating the stream should indeed close it all the way to the server - it's entirely possible that that is not currently the case yet, but I think I'd consider that a bug - possibly also related to the changes currently going on in #201.

@peteremiljensen
Copy link
Author

Yes. Unfortunately, it doesn't seem to close the stream on the server.
But I'm on release v0.1 and not the master branch.

@raboof raboof added the bug Something isn't working label May 25, 2018
@patriknw patriknw self-assigned this Jun 29, 2018
@patriknw
Copy link
Member

I started looking at this.

It's correct that the streaming calls continue when after we have done channel.shutdown. Otherwise we should use channel.shutdownNow.

We could also install KillSwitch in the streams if that is a more graceful way to close things.

I'm not sure what we would want to support?

  • shutdownNow
  • shutdown
  • shutdown + KillSwitch

Perhaps the full graceful shutdown (without KillSwitch) might be difficult to implement later when we switch to Akka HTTP client?

I think I'll start by simply changing it to shutdownNow.

This is perhaps also related to my comment about exposing the client close state in https://github.com/akka/akka-grpc/pull/260/files#r199136901

When we are at it I think we should call channel.shutdownNow when the actor system has terminated.

@patriknw patriknw changed the title Help Wanted: Client close doesn't kill stream on server Client close doesn't kill stream on server Jun 29, 2018
patriknw added a commit that referenced this issue Jun 29, 2018
* and close client when ActorSystem has terminated
@peteremiljensen
Copy link
Author

Furthermore, it would be nice if I could close a specific stream without closing the client. Right now if I KillSwitch an infinite stream, it continues streaming on the server-side

@peteremiljensen
Copy link
Author

peteremiljensen commented Jun 29, 2018

Sorry, I can confirm that KillSwitching works for an infinite stream

@raboof
Copy link
Member

raboof commented Jul 4, 2018

@peteremiljensen I think #264 should resolve the issue - feel free to reopen (or open a new ticket) when you have any further comments though!

@raboof raboof closed this as completed Jul 4, 2018
@peteremiljensen
Copy link
Author

Sounds good. Than you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working client in progress
Projects
None yet
Development

No branches or pull requests

3 participants