Results 1 to 2 of 2

Thread: QWebSocket closeCode not returning expected value

  1. #1
    Join Date
    Dec 2013
    Location
    Chicago
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default QWebSocket closeCode not returning expected value

    Hello,

    I have a C++ Qt application that uses QWebSocket which connects to a server that uses uWS. When the server closes the websocket and specifies a close code and close reason, QWebSocket::closeCode() returns 1002 and closeReason(): "Invalid close code 1002 detected." This is even when I have the server send a close code that is not 1002 and a customized message for close reason. It has worked correctly in some cases, but I'm still trying to find out what makes it misbehave. I first thought that it was because the server was not sending a valid close code, because initially I was using 404, which is invalid, but then I changed it to test the close code values in QWebSocketProtocol::CloseCode, but the issue persists. Is there a specific reason why QWebSocket::closeCode() would return 1002 even though the server is sending a valid close code? Any help would be appreciated.

    The application uses Qt 5.12.3 with mingw 7.3.0 32-bit on Windows.

    Thanks,
    Alex

  2. #2
    Join Date
    Dec 2013
    Location
    Chicago
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QWebSocket closeCode not returning expected value

    The problem was that I was using close codes 1000-1015 and QWebsocket appeared to be disagreeing with their usage and reported 1002, probably because they were being misused. The solution was to just use close codes in the 4000+ range.

Similar Threads

  1. Replies: 0
    Last Post: 7th December 2017, 18:33
  2. QWebChannel - QWebSocket - threading problem
    By RafalNiewinski in forum Qt Programming
    Replies: 5
    Last Post: 8th December 2016, 15:16
  3. Need help handling received messages with QWebSocket based GUI
    By JaffaMicrobrain in forum Qt Programming
    Replies: 5
    Last Post: 26th August 2015, 16:22
  4. Returning from Dialog
    By SSqt5.2 in forum Newbie
    Replies: 9
    Last Post: 20th October 2014, 10:16
  5. Replies: 1
    Last Post: 15th October 2014, 21:00

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.