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 open timeout

QWebSocket open timeout

Scheduled Pinned Locked Moved Unsolved General and Desktop
websockettimeout
2 Posts 2 Posters 3.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.
  • mistralegnaM Offline
    mistralegnaM Offline
    mistralegna
    wrote on last edited by
    #1

    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!

    Ni.SumiN 1 Reply Last reply
    0
    • mistralegnaM mistralegna

      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!

      Ni.SumiN Offline
      Ni.SumiN Offline
      Ni.Sumi
      wrote on last edited by Ni.Sumi
      #2

      @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.

      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