Close channels from Server sides

39 views
Skip to first unread message

Anh Le

unread,
Oct 30, 2017, 11:41:06 PM10/30/17
to grpc.io

When I use an interceptor to authenticate clients (in bi-directional streaming scenarios), if unauthenticated clients refuse to shutdown their channels, how can I forcefully close connections and reclaim opened file descriptors?


Here's the code for the interceptor (assuming that I reject all gRPC calls) and it doesn't work.

@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
    ServerCall<ReqT, RespT> call,
    final Metadata requestHeaders,
    ServerCallHandler<ReqT, RespT> next) {

	call.close(Status.CANCELLED, requestHeaders);
	return new ServerCall.Listener() {

	};

}

Carl Mastrangelo

unread,
Oct 31, 2017, 1:19:03 PM10/31/17
to grpc.io
On the server side you can set NettyServerBuilder.maxConnectionAge() and related methods to limit how long idle clients are connected.

Anh Le

unread,
Nov 1, 2017, 3:31:55 AM11/1/17
to grpc.io
@Carl: Great advice! Thank you.
Reply all
Reply to author
Forward
0 new messages