Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-114235

Sec-WebSocket-Protocol missing for WebSockets in WebAssembly targets

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 6.5.1
    • WebSockets
    • None
    • Emscripten 3.1.25. Qt v6.5.1 for Linux Desktop (Debian Bookworm) x64.
    • WebAssembly

    Description

      Using the "WebSockets MQTT Subscription Example" compiled to a WebAssembly target the "Sec-WebSocket-Protocol" is missing from the list of headers.  Tested against a Mosquitto broker which ignores the client when the subprotocol is not set correctly.  Wireshark trace shows that it is missing from the WASM target.  The response message "Switching Protocols" doesn't contain the subprotocol header so the communication fails to continue correctly.

      Compiling the same exact code for C++ works as expected.
      https://doc.qt.io/qt-6/qtmqtt-websocketsubscription-example.html

      Note: I hard-coded the default command line options for my setup.

      WASM target from Wireshark for initial WebSocket connection:

      Hypertext Transfer Protocol
          GET / HTTP/1.1\r\n
          Host: 10.101.30.101:9001\r\n
          Connection: Upgrade\r\n
          Pragma: no-cache\r\n
          Cache-Control: no-cache\r\n
          User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36\r\n
          Upgrade: websocket\r\n
          Origin: http://localhost:8080\r\n
          Sec-WebSocket-Version: 13\r\n
          Accept-Encoding: gzip, deflate\r\n
          Accept-Language: en-US,en;q=0.9\r\n
          Sec-WebSocket-Key: 3x3wFkBbMUcr42Q4mH4bww==\r\n
          Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits\r\n
          \r\n
          [Full request URI: http://10.101.30.101:9001/]
          [HTTP request 1/1]
          [Response in frame: 886] 

      C++ target for initial WebSocket connection:

      Hypertext Transfer Protocol
          GET / HTTP/1.1\r\n
          Host: 10.101.30.101:9001\r\n
          Upgrade: websocket\r\n
          Connection: Upgrade\r\n
          Sec-WebSocket-Key: MTjWOjycHIQ8o9NiYZoZcA==\r\n
          Sec-WebSocket-Version: 13\r\n
          Sec-WebSocket-Protocol: mqttv3.1\r\n
          \r\n
          [Full request URI: http://10.101.30.101:9001/]
          [HTTP request 1/1]
          [Response in frame: 90] 

      Mosquitto configuration file:

      listener 9001
      protocol websockets
      allow_anonymous true 

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tpochep Timur Pocheptsov
            williamdavy William Davy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes