The WebSocket connection to the MQTT server stops working after placing the application on the GitHub server.
-
I am trying to run the WebSockets MQTT Subscription Example under WebAssembly, which I found here: https://doc.qt.io/qt-6/qtmqtt-websocketsubscription-example.html. To do this, I downloaded the Qt MQTT module, compiled it and ran the example. Generally, everything works fine on my computer, both if the project is run as a desktop and as a web assembly under the browser, I can see in the browser logs that the application connects to the MQTT server and receives messages. The problem occurred when I uploaded the project to the server at https://rafal-tarnow.github.io/websocketsubscription.html. In the browser logs, I see that the project is loaded and trying to connect to the MQTT server and at this moment nothing else happens. What might be the cause that if I run the project locally in the browser it can connect to the MQTT server but if the project is running from the GitHub server it does not work? I slightly modified the main file:
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QCoreApplication::setApplicationVersion("1.0");QString topic = "testOutTopic"; ClientSubscription clientsub; clientsub.setUrl(QUrl("ws://broker.hivemq.com:8000/mqtt")); clientsub.setTopic(topic); //clientsub.setVersion(4); clientsub.setVersion(3); clientsub.connectAndSubscribe(); qDebug() << "Topic = " << topic; return a.exec();
}
-
Hi,
Did you check that GitHub allows connection to server on arbitrary ports ?
-
I found one problem, when app is downloaded to browser via https protocol, browser don't allow use non encrypted WebSockets, but this problem can be omitted by changing browser security policy (for Firefox go to about:config site and set network.websocket.allowInsecureFromHTTPS to true). But the problem still occur. I don't thing that is GitHub allows connection to server on arbitrary ports problem, because application is downloaded to browser and connection to mqtt server is called form there, not form GitHub, but I check that.
-
-
Any luck with the issue? I have a similar problem, when serving my Qt WASM application over HTTPS. I have not secured WebSockets in my app (as SSL seems not to work for Qt WASM) and everything works perfectly fine as long as I serve it over HTTP. When I only change it to HTTPS, even with the browser config appropriately set to handle such cases, no messages are sent from the Qt app.
-
found one point in firefox, you have to accept a self signed certificate for the 443 port (https) and for the port of your websocket request (may be 1234).
call your adress https://192.168.1.1 to load the wasm app and then call https:192.168.1.1:1234 for your connection to the websocket server and accept the certificate