aborting request in ServerInterceptor

59 views
Skip to first unread message

Eugene Strulyov

unread,
Jan 7, 2017, 3:27:43 PM1/7/17
to grpc.io
What is the proper way to abort a call in grpc-java  ServerInterceptor? interceptCall() returns 

 ServerCall.Listener() and the javadoc says it must not be null. The only examples I found return next.startCall().


thanks,


Eugene


Josh Humphries

unread,
Jan 7, 2017, 4:03:18 PM1/7/17
to Eugene Strulyov, grpc.io
In that case, you'd return a dummy (no op) listener and immediately call "serverCall.close(errorStatus, optionalTrailers)" to abort the operation.

----

Josh Humphries

FullStory  |  Atlanta, GA

Software Engineer

j...@fullstory.com


--
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 grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/51ba9e02-c7b7-447c-8282-61dc9981e7d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eugene Strulyov

unread,
Jan 7, 2017, 4:09:03 PM1/7/17
to grpc.io, eugene....@gmail.com, j...@fullstory.com
Will the following code work?

        Metadata trailers = new Metadata();

        call.close(Status.UNAUTHENTICATED, trailers);

        return new ServerCall.Listener<ReqT>() {};


Also, do I need to put anything in trailers or is it just to provide additional information to the caller?


thanks,


Eugene



On Saturday, January 7, 2017 at 1:03:18 PM UTC-8, Josh Humphries wrote:
In that case, you'd return a dummy (no op) listener and immediately call "serverCall.close(errorStatus, optionalTrailers)" to abort the operation.

----

Josh Humphries

FullStory  |  Atlanta, GA

Software Engineer

j...@fullstory.com


On Sat, Jan 7, 2017 at 3:27 PM, Eugene Strulyov <eugene....@gmail.com> wrote:
What is the proper way to abort a call in grpc-java  ServerInterceptor? interceptCall() returns 

 ServerCall.Listener() and the javadoc says it must not be null. The only examples I found return next.startCall().


thanks,


Eugene


--
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 grpc-io+u...@googlegroups.com.

Josh Humphries

unread,
Jan 7, 2017, 4:17:17 PM1/7/17
to Eugene Strulyov, grpc.io
That looks right to me. Give it a try.

Supplying trailer metadata is optional, so the empty metadata in your example should be fine.

----

Josh Humphries

FullStory  |  Atlanta, GA

Software Engineer

j...@fullstory.com


Reply all
Reply to author
Forward
0 new messages