Skip to content

WebSocket KeepAlive section improvements #44731

Open
@CarnaViire

Description

@CarnaViire

Describe the issue or suggestion

Follow-ups from #44611

  • 1. Use xrefs (WebSocket Keep-Alive #44611 (comment), WebSocket Keep-Alive #44611 (comment), WebSocket Keep-Alive #44611 (comment))

    • 1.1.

      1. Keep-Alive is **OFF**, if
      - `KeepAliveInterval` is `TimeSpan.Zero` or `Timeout.InfiniteTimeSpan`
      2. **Unsolicited PONG**, if
      - `KeepAliveInterval` is a positive finite `TimeSpan`, -AND-
      - `KeepAliveTimeout` is `TimeSpan.Zero` or `Timeout.InfiniteTimeSpan`
      3. **PING/PONG**, if
      - `KeepAliveInterval` is a positive finite `TimeSpan`, -AND-
      - `KeepAliveTimeout` is a positive finite `TimeSpan`

      It would be better to use <xref> here instead of code blocks.

    • 1.2.

      > Currently, `WebSocket` ONLY processes incoming frames while there's a `ReceiveAsync` pending.

      > Currently, `WebSocket` ONLY processes incoming frames while there's a <xref:System.Net.WebSockets.WebSocket.ReceiveAsync%2A> task pending.
    • 1.3.

      If the timeout elapses, an outstanding `ReceiveAsync` throws an `OperationCanceledException`:

      If the timeout elapses, an outstanding <xref:System.Net.WebSockets.WebSocket.ReceiveAsync%2A> throws an <xref:System.OperationCanceledException>:
      
  • 2. Reword to clarify this is an implication (WebSocket Keep-Alive #44611 (comment))

    If you want to switch to the PING/PONG strategy, overriding <xref:System.Net.WebSockets.ClientWebSocketOptions.KeepAliveTimeout?displayProperty=nameWithType> is enough:

    Would be good suggest that this is an implication of the behavior described before.

    As a result, overriding <xref:System.Net.WebSockets.ClientWebSocketOptions.KeepAliveTimeout?displayProperty=nameWithType> is enough to switch to the PING/PONG strategy if you keep the default value for <xref:System.Net.WebSockets.WebSocket.DefaultKeepAliveInterval?displayProperty=nameWithType>:
    
  • 3. Reword sentence conjunctions (WebSocket Keep-Alive #44611 (comment))

    > If you want to use Keep-Alive Timeout, it's _crucial_ that PONG responses are _promptly processed_. Even if the remote endpoint is alive and properly sends the PONG response, but the `WebSocket` isn't processing the incoming frames, the Keep-Alive mechanism can issue a "false-positive" Abort. This problem can happen if the PONG frame is never picked up from the transport stream before the timeout elapsed.

    > If you want to use Keep-Alive Timeout, it's _crucial_ that PONG responses are _promptly processed_. Even when the remote endpoint is alive and properly sends the PONG response, if the `WebSocket` isn't processing the incoming frames, the Keep-Alive mechanism can issue a "false-positive" Abort. This problem can happen if the PONG frame is never picked up from the transport stream before the timeout elapsed.
    
  • 4. Fix typo (Minor grammar issue in websocket docs. #44952)

    There is a sentence that starts about two thirds of the way through the "Keep-Alive strategies" section of the article that begins "They sent regularly with KeepAliveInterval intervals...". Nothing major but I think "They sent" should probably be "They are sent".

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions