Skip to content

Http2Connection throws misleading exceptions on ping timeouts #102623

@MihaZupan

Description

@MihaZupan

If the server doesn't respond to our pings in time, we'll currently throw a protocol exception

case KeepAliveState.PingSent:
if (now > _keepAlivePingTimeoutTimestamp)
ThrowProtocolError();

with the exception looking something like this

The HTTP/2 server sent invalid data on the connection. HTTP/2 error code 'PROTOCOL_ERROR' (0x1). (HttpProtocolError)
 ---> System.Net.Http.HttpProtocolException: The HTTP/2 server sent invalid data on the connection. HTTP/2 error code 'PROTOCOL_ERROR' (0x1). (HttpProtocolError)
   at System.Net.Http.Http2Connection.ThrowProtocolError(Http2ProtocolErrorCode errorCode, String message)
   at System.Net.Http.Http2Connection.VerifyKeepAlive()
   at System.Net.Http.Http2Connection.HeartBeat()

which is misleading since the server didn't send us invalid data, we just didn't hear back from it in time.

We should add a useful exception message for this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions