Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWebsocket signal disconnected and method close unrelated ??
QtWS25 Last Chance

QWebsocket signal disconnected and method close unrelated ??

Scheduled Pinned Locked Moved Solved General and Desktop
qwebsocketwebsocketdisconnectedcloseclosecode
4 Posts 2 Posters 2.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nameAlreadyInUse
    wrote on last edited by nameAlreadyInUse
    #1

    Hi,

    If you saw my previous question this one ain't related (I try to go on with my project without ssl until I know how to use it correctly).

    Here what I did :
    Take the SslEchoClient from qt examples and add this line :

    connect(&m_webSocket, &QWebSocket::disconnected,  this,  SslEchoClient::onClose);
    

    to void SslEchoClient::onConnected();
    Then I add The simple method below :

    void SslEchoClient::onClose(){
        qDebug() << "Close code:" << m_webSocket.closeCode();
    }
    

    I then took SslEchoServer and added that line :

            pClient->close(QWebSocketProtocol::CloseCodeProtocolError);
    

    after the line

    pClient->sendTextMessage(message);
    

    The Client debug output is
    Message received: "Hello, world!"
    Close code: 1000

    which is the value for the default closeCode : the normal close code... why ?

    1 Reply Last reply
    0
    • kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      Hello,
      Does this answer your question?

      Kind regards.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nameAlreadyInUse
        wrote on last edited by nameAlreadyInUse
        #3

        Hmmm not really dude : the server close with
        pClient->close(QWebSocketProtocol::CloseCodeProtocolError);

        as mentioned in my previous post;
        but the client output 1000 which is QWebSocketProtocol::CloseCodeNormal

        So the given link just confirm there's a bug or disconnected and close are not realted (which sounds wrong)

        1 Reply Last reply
        0
        • N Offline
          N Offline
          nameAlreadyInUse
          wrote on last edited by nameAlreadyInUse
          #4

          OK guys i can confirm this is a bug in the Qt5.3 (linux version at least); as the exact same code on Qt5.5 on windows produces the followin output :
          Message received: "Hello, world!"
          Close code: 1002

          Was already reported btw : [https://bugreports.qt.io/browse/QTBUG-42982](link url)

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved