0

I take an example of EchoClient from Qt repository:

https://code.qt.io/cgit/qt/qtwebsockets.git/tree/examples/websockets/echoclient?h=5.14&id=66ea748c2ba1fa35c78c5d55742a982976b07435

I've made only single one modification, I changed URL address I would like to connect to:

EchoClient client(QUrl("wss://echo.websocket.org"), true);

And it doesn't work, expected result is that onConnected callback will fire, look on code below.

I've added error callback:

EchoClient::EchoClient(const QUrl &url, bool debug, QObject *parent) :
    QObject(parent),
    m_url(url),
    m_debug(debug)
{
    m_webSocket = new QWebSocket;
    if (m_debug)
        qDebug() << "WebSocket server:" << url;
    connect(m_webSocket, &QWebSocket::connected, this, &EchoClient::onConnected);
    connect(m_webSocket, &QWebSocket::disconnected, this, &EchoClient::closed);
    connect(m_webSocket, QOverload<QAbstractSocket::SocketError>::of(&QWebSocket::error),
        [=](QAbstractSocket::SocketError error)
    {
        qDebug() << "error: " << error;
    });
    QNetworkRequest request=QNetworkRequest(QUrl(url));
    m_webSocket->open(request);
}

and what I see is that Qt always returns

QAbstractSocket::UnsupportedSocketOperationError (10) QAbstractSocket::SocketError

What I'm doing wrong? What is the reason for this error?

StNickolay
  • 950
  • 2
  • 9
  • 21
  • 1
    In Linux with Qt 5.14.2 it works correctly: *WebSocket server: QUrl("wss://echo.websocket.org") WebSocket connected Message received: "Hello, world!"* – eyllanesc Apr 23 '20 at 15:17
  • @eyllanesc Yep looks like it's problem with my setup, I'm on Win8.1, so far I go bit detailed description from Qt: SSL Sockets are not supported on this platform – StNickolay Apr 23 '20 at 15:48
  • See https://stackoverflow.com/questions/33141315/ssl-sockets-not-supported-error – eyllanesc Apr 23 '20 at 15:56
  • @eyllanesc yeah, I saw this, but acording to DEpendency Walker my app doesn't have dependency on ssl.lib, and I don't want to build Qt from sources, so I'm continue googling – StNickolay Apr 23 '20 at 16:03
  • 1
    I recommend you install ssl on your OS (add its directory to the PATH of the environment variables) – eyllanesc Apr 23 '20 at 16:05
  • @eyllanesc thank you! It does the trick, I downloaded by this link http://slproweb.com/products/Win32OpenSSL.html – StNickolay Apr 23 '20 at 16:25
  • Is your Qt installation for mingw or VS? Is it 32 bit or 64 bit? remember that binaries must be compatible. – eyllanesc Apr 23 '20 at 16:32
  • mingw 64 bit, all out of the box, uniqied installer – StNickolay Apr 23 '20 at 16:45

1 Answers1

0

It requires that OpenSSL SHALL be installed on the system. In spite of the fact that Qt installer puts some Open SSL libs to Qt\Tools folder, it's not enough to get it work properly.

StNickolay
  • 950
  • 2
  • 9
  • 21