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

QtWebsockets client fails handshake if there is delay between response status line and headers

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.6.2
    • 5.5.1
    • WebSockets
    • e66dcd51d0e5517e88cd59912fd08501522a2902

    Description

      If there is a delay between status line ("HTTP/1.1 101 Upgrading Protocol") and headers, QWebSocketPrivate::processHandshake erroneously detects server disconnect. The problem is that disconnect condition is checked using QAbstractSocket::atEnd function which just checks if data available and not the actual socket state. This results in multiple error signals:

      websocket error: QWebSocket::processHandshake: Connection closed while reading header.
      websocket error: Invalid statusline in response: Date: Thu, 11 Feb 2016 20:07:37 GMT^M .
      websocket error: Invalid statusline in response: Server: WSGIServer/0.1 Python/2.7.10^M .
      websocket error: Invalid statusline in response: Upgrade: websocket^M .
      websocket error: Invalid statusline in response: Connection: Upgrade^M .
      websocket error: Invalid statusline in response: Sec-WebSocket-Accept: oQ+NK56UdGrsXFisB9chjE3SU+Y=^M .
      websocket error: Invalid statusline in response: Sec-WebSocket-Version: 13^M .
      websocket error: Invalid statusline in response: Content-Length: 0^M .
      websocket error: Invalid statusline in response: ^M .

      You can reproduce bug using attached server.py. It simulates HTTP server and introduces delay between status line and headers.

      Attached patch fixes the problem.

      Attachments

        1. server.py
          2 kB
          Oleksandr
        2. qwebsocket-readingheaders-fix.diff
          0.6 kB
          Oleksandr
        For Gerrit Dashboard: QTBUG-51069
        # Subject Branch Project Status CR V

        Activity

          People

            gonzoua Oleksandr
            gonzoua Oleksandr
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes