Hello,
I have a GRPC protocol I'm working on where I want the ServerInterceptor to
terminate the call if I find the metadata invalid. What is the correct way
to do it while returning an appropriate status code (permission denied in
this case). I'm currently calling call.close() in the interceptor but then
returning the original next.startCall(). The next.startCall() throws an
exception because it is trying to work against a now closed connection. The
method declaration doesn't allow throwing a StatusException. I'm sure there
is an example of this somewhere but I didn't run across it. Example of
current code below:
public class ServerAuthInterceptor implements ServerInterceptor {
@Override
public <ReqT, RespT> Listener<ReqT> interceptCall(ServerCall<ReqT, RespT>
call, Metadata headers,
ServerCallHandler<ReqT, RespT> next) {
if (!MyThing.isValid(headers)) {
call.close(Status.PERMISSION_DENIED, new Metadata());
// TODO: what do we return here to avoid the exception caused by
startCall below?
}
return next.startCall(call, headers);
}
}
Thanks!
--
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 [email protected].
To post to this group, send email to [email protected].
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/e039927e-163c-489f-9fc6-e6634fe2d088%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.