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

How to know the client cancels/exits in a server-only streaming call #76

Closed
met-pub opened this issue May 12, 2018 · 4 comments
Closed
Labels
question A question about this library or its usage

Comments

@met-pub
Copy link

met-pub commented May 12, 2018

In a server-only streaming call, when the client exit unexpectedly (like network error), how does the server know (like Exception or signal) and stop the stream?

@uweschaefer
Copy link
Contributor

I'd love to know as well...

@ST-DDT
Copy link
Collaborator

ST-DDT commented Oct 25, 2018

I assume this question is probably better suited in the grpc-java repo, because this library does not provide or change the behavior of the grpc-stuff.

@ST-DDT
Copy link
Collaborator

ST-DDT commented Nov 27, 2018

There is an example within the grpc code.

The grpc health service has a method called watch, which publishes updates after the initial call.

https://github.com/grpc/grpc-java/blob/master/services/src/main/java/io/grpc/services/HealthServiceImpl.java#L84

Context.current().addListener(
        new CancellationListener() {
            @Override
            // Called when the client has closed the stream
            public void cancelled(Context context) {
                doCleanup();
            }
        },
        MoreExecutors.directExecutor());

Does this answer your question?

@ST-DDT ST-DDT added the question A question about this library or its usage label Nov 27, 2018
@ST-DDT
Copy link
Collaborator

ST-DDT commented Dec 15, 2018

I assume the question is answered. If not please leave a comment.

@ST-DDT ST-DDT closed this as completed Dec 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question about this library or its usage
Projects
None yet
Development

No branches or pull requests

3 participants