nw_socket_get_input_frames [C4:1] recvmsg(fd 35, 9216 bytes) [61: Connection refused] - swift

We're using the Apple's Network.framework and send data between an iOS app and a macOS app using UDP. We use bonjour for discovery. It works great. Until it doesn't...
The problem is that when I stop using the iOS app for like 2-3 minutes (No, I don't quit the app nor do I put it in background. I just don't interact with the UI for this short period of time. Otherwise the iOS app is open and active), the connection stops working. By this I mean I press a button that should send some data to the macOS app but it just stops working and on the macOS Xcode console I see this
The debug log of the macOS app says: 2020-12-01 22:40:40.274638+0100 Our app [10750:497151] [] nwsocketgetinputframes [C4:1] recvmsg(fd 35, 9216 bytes) [61: Connection refused]
What is this and how to heal it? Does the 2-3 min pause as symptom / trigger of the above error message ring some bells?
Maybe the most interesting thing is that when I turn off the wifi on the iOS app the app immediately discovers that the macOS app is gone. And when I turn the wifi back on the iOS app immediately discovers and connects with the macOS app. And yet this doesn't heal the problem. The only thing that does it rebuilding the macOS app in Xcode.

Related

Flutter : keep socket io open while app in background (IOS)

I'm building app that uses flutter_pllayout and adhara_socket_io
App Scenario
When app is launched, it connect to a socket and keep receiving audio urls at random times, then it plays this url, it works fine on android
Problem
but in iOS when user switch to home or any other app (when my app is in background) it seems to close the connection of the socket and continue when app become in foreground, is there any way to keep the socket connection open ?
Background tasks on iOS are very limited. Only works if you play audio constantly with the correct Info.plist details.
If you want recurrent (cron job task) client side, use: BGTaskScheduler (for iOS), one other option is using a cron job triggered push notification task (you can even user Firebase Functions for that) server side.
Official docs: BFTaskScheduler, Background Behavior iOS, Enabling Background Audio
and no, sockets connections can't keep opened all the time (not even on Android on latest versions of their OS). Again, use cron job tasks to achieve a similar behavior.
Officials docs: Android Background limitations

Apple watch and iPhone are not connected when the app in phone goes to background

I ran my iPhone app and its watch extension in the simulator. I send messages from phone to watch and vice versa. The messages are sent and received without any issue. But when I send the iPhone app to background, and then a message is sent from watch to iPhone, I continuously get the following log:
[WC] __33-[WCXPCManager onqueue_reconnect]_block_invoke error reconnecting to daemon due to NSXPCConnectionInterrupted
I searched regarding this but did not find any proper solution. Many have posted it as an issue in the betas of Xcode. I am using the latest Xcode 8.1. What could be the proper solution?

iOS app with iBeacon must restart device

I built a simple ios app with IBeacon . I ran this app on an iPhone 4s whit ios7.1 while running an IBeacon base station.Everything is working right in background or foreground(exit region have 30 seconds delay in background).But over a period of time,about 3 hours,this app can not monitor any event though device setting were not change(blueTooth and locate is normal).This situation must restart the device.
Please tell me what should i do aboult this situation?
Thanks!
I wonder if iOS Bluetooth scanning is slowing down when your app is in the background such that it appears that events never fire because they are just taking so long to happen. Rebooting may speed up the cycle.
One way to force a Bluetooth LE scan cycle to look for iBeacons is to run a different app in the foreground that uses the CoreLocation iBeacon ranging APIs.
Try installing Locate for iBeacon, then as soon as your app appears to be not getting notifications in the basckground, launch Locate for iBeacon and tap Locate iBeacons. Do you see iBeacons? Does your background app get a notification?
If this works, then repeat the test and instead of using the Locate app to force a scan, just wait (an hour if needed). See if you eventually get your notification anyway, and note how long it took.
Edit: it appears that this is a case where iOS stops looking for iBeacons entirely requiring a reboot. See related question below.
iBeacon: didRangeBeacons stops getting called, must reset device for it to work again

iPhone App can autolaunch after device boot?

Saw an app called PhoneRecover on the AppStore.
They advertise the following:
PhoneRecover will automatically restart after a reboot on the iPhone 3GS and the iPhone 4 running iOS4.
How is this possible? What APIs are used to auto-launch an app after a boot?
It's built into multi-tasking. "Backgrounded" apps are still in background after a reboot. Presumably the app does some work to re-instantiate itself and get its state going again the first time Core Location hits it in the background, but there's no other magic happening here. Any background-aware app will survive a reboot in a backgrounded state.
I wouldn't count on this. I was running MotionX GPS and let the battery run completely dead. Upon restart MotionX was no longer running, broadcasting my position or tracking my position. The broadcast option is persistent too (survives app restart).

Application icon not visible on device and exits

Getting the following error while trying to execute the application on device.
The Debugger has exited due to signal 15 (SIGTERM).The Debugger has exited due to signal 15 (SIGTERM).
The application runs fine while connected with USB port, if i disconnect the USB from the device getting this error. Also the application icon is not visible on the device. If i search for the application, it is there on the device.
The changes done in sqlite is also not getting reflected in the application.
The application works fine on simulator
Unless the app requires communication via USB in normal operation don't bother about Xcode complains. A similar thing will happen if you an app is terminated by double tapping the home button and then "deleting" it from background.
The file system on the device is case sensitive, the simulator is not. Check the spelling of your image name.
And save your data before entering background, not only on appWillTerminate