Skip to content

Commit

Permalink
Include number of maximum active streams in exception message (#11644)
Browse files Browse the repository at this point in the history
Motivation:

When users receive "Maximum active streams violated for this endpoint"
exception, it's useful to know what is the current max streams limit on
HTTP/2 connection.

Modifications:

- Include current number of maximum active streams in exception message;

Result:

Easier debugging of HTTP/2 connections.
  • Loading branch information
idelpivnitskiy authored and normanmaurer committed Sep 3, 2021
1 parent ced712d commit 3a1a3de
Showing 1 changed file with 6 additions and 3 deletions.
Expand Up @@ -474,8 +474,10 @@ public final <V> V removeProperty(PropertyKey key) {
@Override
public Http2Stream open(boolean halfClosed) throws Http2Exception {
state = activeState(id, state, isLocal(), halfClosed);
if (!createdBy().canOpenStream()) {
throw connectionError(PROTOCOL_ERROR, "Maximum active streams violated for this endpoint.");
final DefaultEndpoint<? extends Http2FlowController> endpoint = createdBy();
if (!endpoint.canOpenStream()) {
throw connectionError(PROTOCOL_ERROR, "Maximum active streams violated for this endpoint: " +
endpoint.maxActiveStreams());
}

activate();
Expand Down Expand Up @@ -888,7 +890,8 @@ private void checkNewStreamAllowed(int streamId, State state) throws Http2Except
}
boolean isReserved = state == RESERVED_LOCAL || state == RESERVED_REMOTE;
if (!isReserved && !canOpenStream() || isReserved && numStreams >= maxStreams) {
throw streamError(streamId, REFUSED_STREAM, "Maximum active streams violated for this endpoint.");
throw streamError(streamId, REFUSED_STREAM, "Maximum active streams violated for this endpoint: " +
(isReserved ? maxStreams : maxActiveStreams));
}
if (isClosed()) {
throw connectionError(INTERNAL_ERROR, "Attempted to create stream id %d after connection was closed",
Expand Down

0 comments on commit 3a1a3de

Please sign in to comment.