diff --git a/src/libraries/System.Net.Http/src/Resources/Strings.resx b/src/libraries/System.Net.Http/src/Resources/Strings.resx index ca69a570c984fc..76b462010f6866 100644 --- a/src/libraries/System.Net.Http/src/Resources/Strings.resx +++ b/src/libraries/System.Net.Http/src/Resources/Strings.resx @@ -417,6 +417,9 @@ An HTTP/2 connection could not be established because the server did not complete the HTTP/2 handshake. + + The HTTP/2 connection keepalive ping did not respond within timeout {0}ms. + The initial HTTP/2 stream window size must be between {0} and {1}. diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs index e91ccefff630f3..5304e1367676d1 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs @@ -2136,7 +2136,7 @@ private void VerifyKeepAlive() break; case KeepAliveState.PingSent: if (now > _keepAlivePingTimeoutTimestamp) - ThrowProtocolError(); + ThrowKeepAlivePingTimeoutError(_keepAlivePingTimeout); break; default: Debug.Fail($"Unexpected keep alive state ({_keepAliveState})"); @@ -2175,5 +2175,9 @@ private static void ThrowProtocolError() => [DoesNotReturn] private static void ThrowProtocolError(Http2ProtocolErrorCode errorCode, string? message = null) => throw HttpProtocolException.CreateHttp2ConnectionException(errorCode, message); + + [DoesNotReturn] + private static void ThrowKeepAlivePingTimeoutError(long keepAlivePingTimeout) => + ThrowProtocolError(Http2ProtocolErrorCode.ProtocolError, SR.Format(SR.net_http_http2_keepalive_ping_timeout, keepAlivePingTimeout)); } }