QWebsocket signal disconnected and method close unrelated ??



  • 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 ?


  • Qt Champions 2016

    Hello,
    Does this answer your question?

    Kind regards.



  • 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)



  • 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)



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.