Important: Please read the Qt Code of Conduct -

Connection from Qwebview to Qwebsocketserver problem

  • Hello,
    I have an application wherein i use a qwebsocketserver and qwebview. I load the web socket client html file from the web socket chat client example, in the qwebview instance. The result is that no new connection is received in the websocketserver.

    When i load the same ws client example html in firefox or chrome, new ws connections are received in the ws server.

    When i open the qwebview inspector console, an error about invalid utf-8 sequence is showing up

    I use qt 5.5.1

    Installed qt 5.6 beta, and used browser examples to load the ws html. Still no new connection rcvd in ws server.

    Can anybody give me a hint how to solve this problem.

    I inspected with wireshark what is being send by:

    GET / HTTP/1.1
    Upgrade: websocket
    Connection: Upgrade
    Origin: file://
    Pragma: no-cache
    Cache-Control: no-cache
    Sec-WebSocket-Key: Ui7g46fJv4/VZTjwJMu7UA==
    Sec-WebSocket-Version: 13
    Sec-WebSocket-Extensions: x-webkit-deflate-frame
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/538.1 (KHTML, like Gecko) TestGui Safari/538.1

    GET / HTTP/1.1
    User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:40.0) Gecko/20100101 Firefox/40.1.0 Waterfox/40.1.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
    Accept-Language: en-US,en;q=0.5
    Accept-Encoding: gzip, deflate
    DNT: 1
    Sec-WebSocket-Version: 13
    Origin: null
    Sec-WebSocket-Extensions: permessage-deflate
    Sec-WebSocket-Key: 1FCDteKWdkgu0xvFGpU2Rg==
    Connection: keep-alive, Upgrade
    Pragma: no-cache
    Cache-Control: no-cache
    Upgrade: websocket

    The Firefox version could establish a websocket connection.
    Thanks in advance.

  • @TeunGri173
    I did a test against with QWebView in my application. This test is working correctly.

    So there is someting with the QWebSocketServer I use.
    The only I do is:
    ws = new QWebSocketServer("", QWebSocketServer::NonSecureMode, this); ws->listen( QHostAddress::Any, 13031);
    And of course connect to the newConnection() signal.

    resume test results:

    Backend Frontend Result QWebView OK FireFox OK Chrome OK
    QWebSocketServer QWebView FAIL
    QWebSocketServer FireFox OK
    QWebSocketServer Chrome OK

    Only the combination QWebSocketServer / QWebView failed.
    Any hints wat to configure in QWebSocketServer ?
    Or could it possibly be a bug ?

    Thanks in advance for your info.