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

QWebSocket::errorString() returns "Unknown Error" for known error conditions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important P3: Somewhat important
    • 5.3.0 Beta1
    • Some future release
    • WebSockets
    • None
    • Qt 5.2.1 Linux x86_64, and Android

      For errors such as "host not found" or "connection refused" the QWebSocket::errorString() method returns the string "Unknown Error" event when the error() method returns the correct error code.

      I've attached a quick test, that attempts to connect to ws://localhost:4343 and prints the errorString on state change.

      The issue seems to be caused by the Ctor for QWebSocketPrivate that sets the value for m_errorString to QWebSocket::tr("Unknown error"), this in turn causes QWebSocketPrivate::errorString() to always fail a check against m_errorString.isEmpty(), and always returning "Unknown Error".

      Attached is also a patch that leaves the default value for m_errorString as empty and sets it in errorString() instead.

        1. errorString.patch
          0.8 kB
          Rui Abreu Ferreira
        2. main.cpp
          0.4 kB
          Rui Abreu Ferreira
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            kurt.pattyn Kurt Pattyn
            raf Rui Abreu Ferreira
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes