Skip to content

actix-ws: Web socket Close frame description causes frame malformation in Chrome/Brave WebSocket clients #508

@Loaki07

Description

@Loaki07

Description

When sending WebSocket close frames with a description field, Chrome and Brave browsers receive malformed data, while Firefox handles it correctly. The malformation is inconsistent but appears to be related to the close frame's description field encoding.

Reproduction

  1. Set up a WebSocket proxy using actix-ws
  2. Send a close frame with description:
session.close(Some(CloseReason {
    code: CloseCode::Normal,
    description: Some("Search completed".to_string())
})).await

Chrome (has malformed data):

Image - This one has spaces at the start which makes the response a invalid json Image

Firefox(no malformed data):

Image
  1. Observe in Chrome/Brave:
  • Malformed data appears: [malformed] 464b85aa11a4e270e81866] Search completed...
  • Issue is inconsistent but reproducible
  • Firefox receives frames correctly

Current Workaround

Skipping the description field in close frames resolves the issue:

session.close(Some(CloseReason {
    code: CloseCode::Normal,
    description: None  // Skip description to avoid malformation
})).await

Environment

  • actix-ws: 0.2.5
  • Chrome/Brave (Chromium-based browsers)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions