why When i run desktop application using qt web assembly it show Application exit with code 1 ?
-
wrote on 23 Jan 2024, 08:18 last edited by
Hi i have created client web assembly application which receive the message sent from the server.
#include "mainwindow.h" #include <QApplication> #include <QtWebSockets/QtWebSockets> #include <QDebug> #include <QProcess> int main(int argc, char *argv[]) { QApplication a(argc, argv); QString lIp= getLIpAdd(); if(lIp.isEmpty()){ qDebug()<<"Failed to rtetrieve the local IP address."; return 1; } QWebSocket socket; socket.open(QUrl("ws://127.0.0.1:12345")); QObject::connect(&socket, &QWebSocket::connected, [&socket] () { qDebug()<< "connected to server "; socket.sendTextMessage("Hello, server ! "); }); QObject::connect(&socket, &QWebSocket::textMessageReceived, [&socket] (const QString &message) { qDebug()<< "Message received from server: "<< message; socket.close(); QApplication::quit(); }); QObject::connect(&socket, &QWebSocket::disconnected,[&socket] () { qDebug()<<"Client disconnected from server" ; }); MainWindow w; w.show(); return a.exec(); }
Now when i run this application in desktop environment it runs perfectly. But when i run this application using qt web assembly kit. it throws the error and not show the ui.
when i inspect the code i found below errors into that
unreachable code after return statement qtloader.js:548:4 Calling stub instead of sigaction() 2 qtloader.js:382:25 Failed to rtetrieve the local IP address. qtloader.js:382:25 Assertion failed: the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits) qtloader.js:372:25 Assertion failed: the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits) qtloader.js:382:25 Uncaught RuntimeError: abort(Assertion failed: the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)) at jsStackTrace@http://localhost:30000/qtloader.js line 443 > eval:1887:17 stackTrace@http://localhost:30000/qtloader.js line 443 > eval:1904:16 abort@http://localhost:30000/qtloader.js line 443 > eval:1662:44 assert@http://localhost:30000/qtloader.js line 443 > eval:716:10 Module.dynCall_vii@http://localhost:30000/qtloader.js line 443 > eval:14034:9 dynCall_vii_84@http://localhost:30000/qtloader.js line 443 > eval line 6844 > Function:4:12 qtResizeAllScreens@http://localhost:30000/qtloader.js line 443 > eval line 6655 > Function:8:8 abort http://localhost:30000/qtloader.js line 443 > eval:1668 assert http://localhost:30000/qtloader.js line 443 > eval:716 dynCall_vii http://localhost:30000/qtloader.js line 443 > eval:14034 dynCall_vii_84 http://localhost:30000/qtloader.js line 443 > eval line 6844 > Function:4 qtResizeAllScreens http://localhost:30000/qtloader.js line 443 > eval line 6655 > Function:8 qtloader.js line 443 > eval:1668:9
Can anybody guide me what can help me for resolve this error and run it using qt web assembly.
-
@jsulm it's function
QString getLIpAdd(){ QProcess p; p.start("hostname", QStringList() << "-I"); p.waitForFinished(); return QString(p.readAll().trimmed()); }
@Qt-embedded-developer I don't think you can start other processes in web assembly applications. There is anyway no need to do such hacks just to get local IP, see for example https://stackoverflow.com/questions/13835989/get-local-ip-address-in-qt
-
Hi i have created client web assembly application which receive the message sent from the server.
#include "mainwindow.h" #include <QApplication> #include <QtWebSockets/QtWebSockets> #include <QDebug> #include <QProcess> int main(int argc, char *argv[]) { QApplication a(argc, argv); QString lIp= getLIpAdd(); if(lIp.isEmpty()){ qDebug()<<"Failed to rtetrieve the local IP address."; return 1; } QWebSocket socket; socket.open(QUrl("ws://127.0.0.1:12345")); QObject::connect(&socket, &QWebSocket::connected, [&socket] () { qDebug()<< "connected to server "; socket.sendTextMessage("Hello, server ! "); }); QObject::connect(&socket, &QWebSocket::textMessageReceived, [&socket] (const QString &message) { qDebug()<< "Message received from server: "<< message; socket.close(); QApplication::quit(); }); QObject::connect(&socket, &QWebSocket::disconnected,[&socket] () { qDebug()<<"Client disconnected from server" ; }); MainWindow w; w.show(); return a.exec(); }
Now when i run this application in desktop environment it runs perfectly. But when i run this application using qt web assembly kit. it throws the error and not show the ui.
when i inspect the code i found below errors into that
unreachable code after return statement qtloader.js:548:4 Calling stub instead of sigaction() 2 qtloader.js:382:25 Failed to rtetrieve the local IP address. qtloader.js:382:25 Assertion failed: the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits) qtloader.js:372:25 Assertion failed: the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits) qtloader.js:382:25 Uncaught RuntimeError: abort(Assertion failed: the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)) at jsStackTrace@http://localhost:30000/qtloader.js line 443 > eval:1887:17 stackTrace@http://localhost:30000/qtloader.js line 443 > eval:1904:16 abort@http://localhost:30000/qtloader.js line 443 > eval:1662:44 assert@http://localhost:30000/qtloader.js line 443 > eval:716:10 Module.dynCall_vii@http://localhost:30000/qtloader.js line 443 > eval:14034:9 dynCall_vii_84@http://localhost:30000/qtloader.js line 443 > eval line 6844 > Function:4:12 qtResizeAllScreens@http://localhost:30000/qtloader.js line 443 > eval line 6655 > Function:8:8 abort http://localhost:30000/qtloader.js line 443 > eval:1668 assert http://localhost:30000/qtloader.js line 443 > eval:716 dynCall_vii http://localhost:30000/qtloader.js line 443 > eval:14034 dynCall_vii_84 http://localhost:30000/qtloader.js line 443 > eval line 6844 > Function:4 qtResizeAllScreens http://localhost:30000/qtloader.js line 443 > eval line 6655 > Function:8 qtloader.js line 443 > eval:1668:9
Can anybody guide me what can help me for resolve this error and run it using qt web assembly.
@Qt-embedded-developer said in why When i run desktop application using qt web assembly it show Application exit with code 1 ?:
getLIpAdd
What is this?
-
@Qt-embedded-developer said in why When i run desktop application using qt web assembly it show Application exit with code 1 ?:
getLIpAdd
What is this?
wrote on 23 Jan 2024, 09:41 last edited by@jsulm it's function
QString getLIpAdd(){ QProcess p; p.start("hostname", QStringList() << "-I"); p.waitForFinished(); return QString(p.readAll().trimmed()); }
-
@jsulm it's function
QString getLIpAdd(){ QProcess p; p.start("hostname", QStringList() << "-I"); p.waitForFinished(); return QString(p.readAll().trimmed()); }
@Qt-embedded-developer I don't think you can start other processes in web assembly applications. There is anyway no need to do such hacks just to get local IP, see for example https://stackoverflow.com/questions/13835989/get-local-ip-address-in-qt
-
@jsulm it's function
QString getLIpAdd(){ QProcess p; p.start("hostname", QStringList() << "-I"); p.waitForFinished(); return QString(p.readAll().trimmed()); }
wrote on 23 Jan 2024, 09:53 last edited by@Qt-embedded-developer I have commented that function in my code. now my server is receiving the my sent message but the client code's console output i can not able to see. as well as my UI is not get shown in the html file. it only show exit code 0 with qt image
-
@Qt-embedded-developer I have commented that function in my code. now my server is receiving the my sent message but the client code's console output i can not able to see. as well as my UI is not get shown in the html file. it only show exit code 0 with qt image
@Qt-embedded-developer Why do you call QApplication::quit() in slot connected to textMessageReceived?
-
@Qt-embedded-developer Why do you call QApplication::quit() in slot connected to textMessageReceived?
wrote on 23 Jan 2024, 09:59 last edited by Qt embedded developer@jsulm Shall i need to remove it ? .i am learning to use this web socket. so one sample i have found and so i use that sample in my code. Can you tell me what changes i need to make so i can see the ui.
-
@jsulm Shall i need to remove it ? .i am learning to use this web socket. so one sample i have found and so i use that sample in my code. Can you tell me what changes i need to make so i can see the ui.
@Qt-embedded-developer Are you aware that QApplication::quit() terminates your application?
-
@Qt-embedded-developer Are you aware that QApplication::quit() terminates your application?
wrote on 24 Jan 2024, 07:04 last edited by@jsulm yes thanks now my application show the ui.
-
1/9