diff --git a/netty/src/main/java/io/grpc/transport/netty/NettyClientHandler.java b/netty/src/main/java/io/grpc/transport/netty/NettyClientHandler.java index f07990d0d3..407782cea9 100644 --- a/netty/src/main/java/io/grpc/transport/netty/NettyClientHandler.java +++ b/netty/src/main/java/io/grpc/transport/netty/NettyClientHandler.java @@ -31,6 +31,7 @@ package io.grpc.transport.netty; +import static io.netty.handler.codec.http2.Http2CodecUtil.getEmbeddedHttp2Exception; import static io.netty.util.CharsetUtil.UTF_8; import com.google.common.annotations.VisibleForTesting; @@ -247,6 +248,17 @@ class NettyClientHandler extends Http2ConnectionHandler { } } + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + if (getEmbeddedHttp2Exception(cause) == null) { + // Kill the connection instead of propagating the exceptionCaught(). Http2ConnectionHandler + // only handles Http2Exceptions and propagates everything else. + goAwayStatus(Status.fromThrowable(cause)); + cause = new Http2Exception(Http2Error.INTERNAL_ERROR, null, cause); + } + super.exceptionCaught(ctx, cause); + } + @Override protected void onConnectionError(ChannelHandlerContext ctx, Throwable cause, Http2Exception http2Ex) {