Skip to content

Handshake with protocol fails for some WebSocket servers #61

Open

Description

I was attempting to switch from tokio_tungstenite to ratchet_rs primarily because this library supports per-message deflate. However, the library does not appear to work for some WebSocket servers as it fails on the handshake.

Here is a minimum reproducible example: https://gist.github.com/eqiy/7de3c543d92dacefafd5551a36211b02

I am not entirely sure of the reason, but I can't reproduce the issue on any other library even across different programming languages, so something ratchet_rs is doing is unique.

Activity

  1. SirCipher commented on Mar 3, 2025

    @SirCipher
    Contributor

    @eqiy, the issue arises because Ratchet writes HTTP headers in lowercase, while the server you're trying to connect to doesn't handle lowercase headers properly; which is interesting as it returns lowercase headers. HTTP header names should be case insensitive when parsed. Although Ratchet isn't technically wrong for using lowercase, many servers enforce incorrect casing rules and to avoid issues, many WebSocket servers opt for using title case headers instead. I'll release an update soon that switches to a more expected title case convention for headers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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