Skip to content

Commit

Permalink
Add debug logs for http2 stream errors (#4515)
Browse files Browse the repository at this point in the history
Motivation:

We sometimes encounter situations where  HTTP/2 header frames are lost due to an exception.
Although a RST frame is sent in this case, remotes are still able to send data for the offending stream, which ends up in error logs which armeria doesn't understand.

e.g.
```
io.netty.handler.codec.http2.Http2Exception: Stream 1147 does not exist
```

Although normally it might be noisy to be alerted of such failures, it might be useful to view such logs when debugging.

Modifications:

- Added logging for HTTP/2 `StreamError`
- Added logging for connection errors just in case as well.

Result:

- Easier to debug http2 failure logs.
  • Loading branch information
jrhee17 authored Nov 7, 2022
1 parent faedf78 commit 1d6eb6f
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import io.netty.handler.codec.http2.Http2ConnectionEncoder;
import io.netty.handler.codec.http2.Http2ConnectionHandler;
import io.netty.handler.codec.http2.Http2Exception;
import io.netty.handler.codec.http2.Http2Exception.StreamException;
import io.netty.handler.codec.http2.Http2Settings;
import io.netty.handler.codec.http2.Http2Stream.State;
import io.netty.handler.codec.http2.Http2StreamVisitor;
Expand Down Expand Up @@ -111,13 +112,20 @@ protected final void onConnectionError(ChannelHandlerContext ctx, boolean outbou

handlingConnectionError = true;
if (Exceptions.isExpected(cause) || isGoAwaySentException(cause, connection())) {
// Ignore silently.
logger.trace("{} HTTP/2 connection error:", ctx.channel(), cause);
} else {
logger.warn("{} HTTP/2 connection error:", ctx.channel(), cause);
}
super.onConnectionError(ctx, outbound, cause, filterHttp2Exception(cause, http2Ex));
}

@Override
protected void onStreamError(ChannelHandlerContext ctx, boolean outbound, Throwable cause,
StreamException http2Ex) {
logger.debug("{} HTTP/2 stream error:", ctx.channel(), cause);
super.onStreamError(ctx, outbound, cause, http2Ex);
}

private static Http2Exception filterHttp2Exception(Throwable cause, @Nullable Http2Exception http2Ex) {
if (http2Ex != null) {
return http2Ex;
Expand Down

0 comments on commit 1d6eb6f

Please sign in to comment.