QWebSocket open timeout



  • Hello all,

    I am using a QWebSocket. I try to open a connection to a secure websocket server. The connection is ok when I use the correct address (wss://), but if I use the address starting by 'ws://' (for example, in the case of a client trying to connect with the wrong address), I am not informed of any error.

    The only signal I get in this case from the websocket is the stateChanged that takes the value ConnectingState.

    Is there a way to ensure, given a specific timeout, the websocket will emit a signal error ?

    Thank you by advance!



  • @mistralegna

    AFAIK,

    You can set bool QAbstractSocket::isValid() const on the given address provided. you can also get error signal from the websocket, if it is not valid address. void QAbstractSocket::error(QAbstractSocket::SocketError socketError). check here .

    But , the isvlaid() is not very efficient like in your case WS:// instead of WSS://. Because to my knowledge isValid() says true to any address , if it is inform of address/standard way of address. In your cases, I prefer to use Regular Expression before connection to socket.


Log in to reply
 

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