Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. iOS network socket being closed on sleep

iOS network socket being closed on sleep

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 4 Posters 2.8k 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.
  • S Offline
    S Offline
    stcorp
    wrote on 20 Mar 2017, 14:51 last edited by stcorp
    #1

    I have an app that communicates with a server using a QSslSocket. On Android, Linux, Windows and macOS, putting the device to sleep keeps the socket connected. However, on iOS, whenever the screen is put to sleep using the sleep button, the socket is disconnected. Does anyone know how to prevent this from happening?

    I've been looking through all the key/values in the info.plist, hoping to find a setting that would change this behavior but so far I have had little luck. I did notice the when I set UIApplicationExitsOnSuspend to true, that then the socket would be kept open when pressing the sleep button, exactly like what I want. However, then pressing the home button completely exits the app instead of putting it in the background, which is undesired behavior for me.

    I've also looked at UIBackgroundModes and UIRequiresPersistentWiFi, but these also didn't help me.

    Does anyone have a solution to this, or am I really going to have to reestablish the socket connection every time the device wakes up?

    If you need more information or want to see some example code, don't hesitate to ask and I'll see what I can do.

    J 1 Reply Last reply 3 May 2017, 09:58
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 21 Mar 2017, 07:59 last edited by
      #2

      Hi,

      AFAIK, there's currently no direct way provided for that with iOS.

      You would have to "work around" that like explained in this stackoverflow post.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S stcorp
        20 Mar 2017, 14:51

        I have an app that communicates with a server using a QSslSocket. On Android, Linux, Windows and macOS, putting the device to sleep keeps the socket connected. However, on iOS, whenever the screen is put to sleep using the sleep button, the socket is disconnected. Does anyone know how to prevent this from happening?

        I've been looking through all the key/values in the info.plist, hoping to find a setting that would change this behavior but so far I have had little luck. I did notice the when I set UIApplicationExitsOnSuspend to true, that then the socket would be kept open when pressing the sleep button, exactly like what I want. However, then pressing the home button completely exits the app instead of putting it in the background, which is undesired behavior for me.

        I've also looked at UIBackgroundModes and UIRequiresPersistentWiFi, but these also didn't help me.

        Does anyone have a solution to this, or am I really going to have to reestablish the socket connection every time the device wakes up?

        If you need more information or want to see some example code, don't hesitate to ask and I'll see what I can do.

        J Offline
        J Offline
        javageek
        wrote on 3 May 2017, 09:58 last edited by
        #3

        @stcorp said in iOS network socket being closed on sleep:

        I have an app that communicates with a server using a QSslSocket. On Android, Linux, Windows and macOS, putting the device to sleep keeps the socket connected. However, on iOS, whenever the screen is put to sleep using the sleep button, the socket is disconnected. Does anyone know how to prevent this from happening?

        I've been looking through all the key/values in the info.plist, hoping to find a setting that would change this behavior but so far I have had little luck. I did notice the when I set UIApplicationExitsOnSuspend to true, that then the socket would be kept open when pressing the sleep button, exactly like what I want. However, then pressing the home button completely exits the app instead of putting it in the background, which is undesired behavior for me.

        I've also looked at UIBackgroundModes and UIRequiresPersistentWiFi, but these also didn't help me.

        Does anyone have a solution to this, or am I really going to have to reestablish the socket connection every time the device wakes up?

        If you need more information or want to see some example code, don't hesitate to ask and I'll see what I can do.

        Also, try to follow link instructions http://developer.apple.com/library/ios/#technotes/tn2277/_index.html . It may help you to resolve your issue.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          James369
          Banned
          wrote on 4 Aug 2018, 06:02 last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          -1

          • Login

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