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. QT android application suddenly disconnect.

QT android application suddenly disconnect.

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 1.4k Views 3 Watching
  • 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.
  • D Offline
    D Offline
    deleted510
    wrote on last edited by
    #1

    Hi guys,

    I am developing C++ qt application that is meant to be multi platform. (Windows, Linux, Android, IOS)

    On the windows and linux i do not have problems, but on the android there is a problem with the connection.

    Application is based on client server communication. And when its working on Android device, it is attached to the server via WiFi.

    The problem is: After running for few hours, sometimes more, sometimes less, application simply disconnect from the server.
    Communication is based on the UDP protocol. I am pretty sure that problem is up to the application, because when i try to reproduce problem with turning off wifi on one or another side (client or server) i got completely other log messages.

    So basically it is like application decide in one moment just to shutdown connection with server. Time for the reproducing bug is always different, sometimes one hour, sometimes ~20hours.

    I also compiled application for ios, and on the Ipad, application was working for ~60hours without disconnection.

    I still do not have much experience with the QT and now i am stuck, i dont know what to do. Can anyone help me please?

    Kind regards,

    Stasa

    K 1 Reply Last reply
    0
    • D deleted510

      Hi guys,

      I am developing C++ qt application that is meant to be multi platform. (Windows, Linux, Android, IOS)

      On the windows and linux i do not have problems, but on the android there is a problem with the connection.

      Application is based on client server communication. And when its working on Android device, it is attached to the server via WiFi.

      The problem is: After running for few hours, sometimes more, sometimes less, application simply disconnect from the server.
      Communication is based on the UDP protocol. I am pretty sure that problem is up to the application, because when i try to reproduce problem with turning off wifi on one or another side (client or server) i got completely other log messages.

      So basically it is like application decide in one moment just to shutdown connection with server. Time for the reproducing bug is always different, sometimes one hour, sometimes ~20hours.

      I also compiled application for ios, and on the Ipad, application was working for ~60hours without disconnection.

      I still do not have much experience with the QT and now i am stuck, i dont know what to do. Can anyone help me please?

      Kind regards,

      Stasa

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @Stasa-Sekulic

      Hi and welcome to devnet forum

      Do you get an error message/code at all?
      Or does it simply disconnect?
      Where do you test Android?
      Is it an Android phone?

      Possibly it has something to do with power saving modes on Android or similar things.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        deleted510
        wrote on last edited by deleted510
        #3

        @koahnig

        No, i did not get error message.

        I have found that it is somehow (still investigating) to the QTcpSocket and disconnected signal, it disconnect because of that, but still i cannot figure out why it happens and how to fix that.

        QTcpSocket *rc_tcpSocket;

        connect(rc_tcpSocket, SIGNAL(disconnected()), this, SLOT(rc_disconnected()) );

        But for some reason this issue never appears on the IOS device.

        I am using Asus Nexus 7 tablet. And i looked for the settings for power save, and turned them off.

        K 1 Reply Last reply
        0
        • D deleted510

          @koahnig

          No, i did not get error message.

          I have found that it is somehow (still investigating) to the QTcpSocket and disconnected signal, it disconnect because of that, but still i cannot figure out why it happens and how to fix that.

          QTcpSocket *rc_tcpSocket;

          connect(rc_tcpSocket, SIGNAL(disconnected()), this, SLOT(rc_disconnected()) );

          But for some reason this issue never appears on the IOS device.

          I am using Asus Nexus 7 tablet. And i looked for the settings for power save, and turned them off.

          K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          @Stasa-Sekulic

          I would expect that this is simply an issue with the Android device, but not a specific issue of Qt on Android.

          However, you are writing in your first post about UDP, but your are using QTcpSocket in your second. What are you using?

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jjdd
            wrote on last edited by
            #5

            I came to this thread because I googled the same issue. It is an Anroid-only issue for me (I develop for Android and for iOS). For iOS it stays connected, even overnight. But for Android, maybe 15 to 30 seconds and then, "biz.mycompany.myapp died" in the Application Output window. (Nothing informative in the logcat.)

            1 Reply Last reply
            0
            • D Offline
              D Offline
              deleted510
              wrote on last edited by
              #6

              @koahnig @jjdd
              Sorry for no update earlier, i have some other issues to solve in parallel.
              About UDP and TCP:

              • Application can connect to the server via LAN and via WLAN

              • For WLAN it uses TCP

              • For LAN it uses UDP

              I have performed again test with more logs, and found that the problem is in THIS LINE
              rc_tcpSocket->waitForConnected(1500)
              after some ,random ,time this is where i get error and client disconnect from the server.

              My opinion that issue is code and device related, but i cannot tell for sure, after i read about QTcpSocket i hope i will find what is causing the issue.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                deleted510
                wrote on last edited by deleted510
                #7

                Hi guys,

                Can someone explain me with a little more details what does this means?
                waitForConnected may fail randomly on Windows, and what is meant by using the event loop and connected() signal?
                I searched everywhere, and wherever I find QT issue with QAbstractSocket, there is so much answers and solutions. And pretty much every solution is kind a workaround.

                Kind regards,

                Staša

                K 1 Reply Last reply
                0
                • D deleted510

                  Hi guys,

                  Can someone explain me with a little more details what does this means?
                  waitForConnected may fail randomly on Windows, and what is meant by using the event loop and connected() signal?
                  I searched everywhere, and wherever I find QT issue with QAbstractSocket, there is so much answers and solutions. And pretty much every solution is kind a workaround.

                  Kind regards,

                  Staša

                  K Offline
                  K Offline
                  koahnig
                  wrote on last edited by
                  #8

                  @Stasa-Sekulic

                  The event loop is required for signal-slot mechanism which is summarized here

                  Vote the answer(s) that helped you to solve your issue(s)

                  1 Reply Last reply
                  1
                  • D Offline
                    D Offline
                    deleted510
                    wrote on last edited by
                    #9

                    I have found solution after some time. Sorry for late update.

                    Problem was that when connected() signal was fired, my application was stuck in for loop, and ignored signal. So the problem was design of the application.

                    K 1 Reply Last reply
                    2
                    • D deleted510

                      I have found solution after some time. Sorry for late update.

                      Problem was that when connected() signal was fired, my application was stuck in for loop, and ignored signal. So the problem was design of the application.

                      K Offline
                      K Offline
                      koahnig
                      wrote on last edited by
                      #10

                      @Stasa-Sekulic said in QT android application suddenly disconnect.:

                      I have found solution after some time. Sorry for late update.

                      Problem was that when connected() signal was fired, my application was stuck in for loop, and ignored signal. So the problem was design of the application.

                      Glad that you have found the solution for your problem.
                      Thanks for reporting back

                      Vote the answer(s) that helped you to solve your issue(s)

                      1 Reply Last reply
                      0

                      • Login

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