Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. why When i run desktop application using qt web assembly it show Application exit with code 1 ?
Forum Updated to NodeBB v4.3 + New Features

why When i run desktop application using qt web assembly it show Application exit with code 1 ?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 2 Posters 569 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by
    #1

    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.

    jsulmJ 1 Reply Last reply
    0
    • Q Qt embedded developer

      @jsulm it's function

      QString getLIpAdd(){
          QProcess p;
          p.start("hostname", QStringList() << "-I");
          p.waitForFinished();
          return QString(p.readAll().trimmed());
      }
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • Q Qt embedded developer

        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.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @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?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        Q 1 Reply Last reply
        1
        • jsulmJ jsulm

          @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?

          Q Offline
          Q Offline
          Qt embedded developer
          wrote on last edited by
          #3

          @jsulm it's function

          QString getLIpAdd(){
              QProcess p;
              p.start("hostname", QStringList() << "-I");
              p.waitForFinished();
              return QString(p.readAll().trimmed());
          }
          
          jsulmJ Q 2 Replies Last reply
          0
          • Q Qt embedded developer

            @jsulm it's function

            QString getLIpAdd(){
                QProcess p;
                p.start("hostname", QStringList() << "-I");
                p.waitForFinished();
                return QString(p.readAll().trimmed());
            }
            
            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @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

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • Q Qt embedded developer

              @jsulm it's function

              QString getLIpAdd(){
                  QProcess p;
                  p.start("hostname", QStringList() << "-I");
                  p.waitForFinished();
                  return QString(p.readAll().trimmed());
              }
              
              Q Offline
              Q Offline
              Qt embedded developer
              wrote on last edited by
              #5

              @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

              jsulmJ 1 Reply Last reply
              0
              • Q Qt embedded developer

                @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

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #6

                @Qt-embedded-developer Why do you call QApplication::quit() in slot connected to textMessageReceived?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                Q 1 Reply Last reply
                2
                • jsulmJ jsulm

                  @Qt-embedded-developer Why do you call QApplication::quit() in slot connected to textMessageReceived?

                  Q Offline
                  Q Offline
                  Qt embedded developer
                  wrote on last edited by Qt embedded developer
                  #7

                  @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.

                  jsulmJ 1 Reply Last reply
                  0
                  • Q 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.

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    @Qt-embedded-developer Are you aware that QApplication::quit() terminates your application?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    Q 1 Reply Last reply
                    2
                    • jsulmJ jsulm

                      @Qt-embedded-developer Are you aware that QApplication::quit() terminates your application?

                      Q Offline
                      Q Offline
                      Qt embedded developer
                      wrote on last edited by
                      #9

                      @jsulm yes thanks now my application show the ui.

                      1 Reply Last reply
                      0
                      • Q Qt embedded developer has marked this topic as solved on

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved