Im unable to use any of the QWebSockets client examples listed here:
The application tries to open the localhost url, the socket gets stuck in QAbstractSocket::ConnectingState and
qDebug() << m_webSocket.error();
Firstly, I don't think ssl is the issue in this case.
I just ran the examples and it just worked fine. Which means there could be one of the following common problems (or there could be others I don't know about).
EchoClient client(QUrl(QStringLiteral("ws://localhost:1234")));and replace
1234with a number like
9001etc should solve the problem. Notice, you have to change port in both client and server program in that case. (Read next point to fully understand in case you don't understand what I am saying.)
Run the client program while the corresponding server program is running. For example, when you are running
echoclient, you are supposed to keep the
echoserver running. If you are in windows or linux, you can do this by opening two Qt Creator process and running the
echoserver first and then
echoclient. If you are in Mac, you can't create two instances of Qt Creator (at least in Yosemite, I don't know about osx lion). You have to run the
echoserver (and don't close the console), then open the
echoclient project and Set echoclient as Active Project and run.
(though not likely) if you are opening a project, copying the cpp files from website and pasting it in your project and then compiling (instead of downloading it form Examples tab of your Qt Creator), then you may be missing configuration of .pro file. Just add
QT += core in the
.pro file of the project.
If these are not the cases, then you can let me know and you can try posting in the Qt forum too in that case.