intermittent "No Route to Host" on iOS, flight mode off then on fixes
My iPhone app uses UDP to communicate over the cell network.
It generally works, except that sometimes the operating system returns "No route to host" (65) on a sendto call, and it never works from that point onwards -- I just keep getting same error, even if I close and reopen the app. However, if I toggle flight mode (presumably resetting the comms stack) and then go back to app, everything works.
I have WiFi switched off so that I can force it to use the cell network. Also, if I get the phone into this not-working state, and open, say, the Stocks app, it briefly says (for about 1 second) "Network Unavailable", before connecting and updating itself. It feels like there's some code in the Stocks app that recognizes the problem and does some kind of reset and retry. I suppose that app uses TCP/IP to talk to a web service.
Who can tell me what's going on, or how I can do the same "reset and retry" that I think Stocks is doing? Any ideas much appreciated :)
Jade
APP (Udp) IS FUNCTIONING NORMALLY, SENDS REQUEST AND GETS RESPONSE
Fri Sep 3 15:48:56 iPhone-de-Jade-Burton Udp[5866] : JDuplicateFilter received packet: index = 0, group = 0, total = 1 Fri Sep 3 15:48:56 iPhone-de-Jade-Burton Udp[5866] : JDuplicateFilter: got group 0, as expected Fri Sep 3 15:48:56 iPhone-de-Jade-Burton Udp[5866] : JDuplicateFilter: added one item. 1 item(s) in set, 1 item(s) in queue Fri Sep 3 15:48:56 iPhone-de-Jade-Burton Udp[5866] : JResender erases packet awaiting ACK: index = 0, group = 0, total = 1 Fri Sep 3 15:48:56 iPhone-de-Jade-Burton Udp[5866] : JMerger: simple 1-packet group, passing through Fri Sep 3 15:48:56 iPhone-de-Jade-Burton Udp[5866] : response
DEBUG SERVER PHONES HOME
Fri Sep 3 15:49:54 iPhone-de-Jade-Burton com.apple.debugserver-48[5871] : debugserver-48 for armv6 Copyright (c) 2007-2009 Apple, Inc. All Rights Reserved. Fri Sep 3 15:49:54 iPhone-de-Jade-Burton com.apple.debugserver-48[5871] : Connecting to com.apple.debugserver service... Fri Sep 3 15:49:55 iPhone-de-Jade-Burton kernel[0] : lockbot[5870] Builtin profile: debugserver (sandbox)
COMMCENTER DEACTIVATES SOMETHING BECAUSE IT HAS NOT BEEN USED FOR 8 MINUTES?
Fri Sep 3 15:57:50 iPhone-de-Jade-Burton CommCenter[31] : Deactiv开发者_StackOverflow社区ating PDP context 0, because it has gone idle. Fri Sep 3 15:57:52 iPhone-de-Jade-Burton configd[24] : .519 (+600.896) SCDynamicStore "network" notification State:/Network/Interface/pdp_ip0/IPv4 : removed Fri Sep 3 15:57:52 iPhone-de-Jade-Burton CommCenter[31] : Deactivated PDP context 0 that supports connection types 0x1
CONFIGD TELLS US THAT THINGS HAVE CHANGED
Fri Sep 3 15:57:52 iPhone-de-Jade-Burton configd[24] : CaptiveNetworkSupport:CaptiveHandleNetworkChanged:2158 key: State:/Network/Service/3A1DA52C-9DBD-4573-9463-C4FEFAF18AF6/IPv4 Fri Sep 3 15:57:52 iPhone-de-Jade-Burton configd[24] : .670 (+0.151) SCDynamicStore "network" notification State:/Network/Service/3A1DA52C-9DBD-4573-9463-C4FEFAF18AF6/IPv4 : removed Fri Sep 3 15:57:52 iPhone-de-Jade-Burton configd[24] : network configuration changed. Fri Sep 3 15:57:52 iPhone-de-Jade-Burton configd[24] : .948 (+0.278) SCDynamicStore "network" notification State:/Network/Global/IPv4 : removed State:/Network/Global/DNS Fri Sep 3 15:57:52 iPhone-de-Jade-Burton configd[24] : .964 (+0.016) dnsinfo notification Fri Sep 3 15:57:52 iPhone-de-Jade-Burton configd[24] : .985 (+0.020) Primary service: removed Fri Sep 3 15:57:53 iPhone-de-Jade-Burton configd[24] : hostname (prefs) = iPhone-de-Jade-Burton
APP (Udp) NO LONGER WORKING, GETS ERROR ON sendto
Fri Sep 3 15:58:39 iPhone-de-Jade-Burton Udp[5866] : JSplitter sending packets Fri Sep 3 15:58:39 iPhone-de-Jade-Burton Udp[5866] : 16 byte(s), index = 1, group = 1, total = 1 Fri Sep 3 15:58:39 iPhone-de-Jade-Burton Udp[5866] : JResender saved packet. total now: 1 Fri Sep 3 15:58:39 iPhone-de-Jade-Burton Udp[5866] : Socket error 65, No route to host Fri Sep 3 15:58:43 iPhone-de-Jade-Burton Udp[5866] : JSplitter sending packets Fri Sep 3 15:58:43 iPhone-de-Jade-Burton Udp[5866] : 16 byte(s), index = 1, group = 2, total = 1 Fri Sep 3 15:58:43 iPhone-de-Jade-Burton Udp[5866] : JResender saved packet. total now: 2 Fri Sep 3 15:58:43 iPhone-de-Jade-Burton Udp[5866] : Socket error 65, No route to host
LAUNCHD LOGGING "BUG"?
Fri Sep 3 15:59:06 iPhone-de-Jade-Burton com.apple.launchd[1] (UIKitApplication:com.yourcompany.Udp[0xeb7c][5866]) : (UIKitApplication:com.yourcompany.Udp[0xeb7c]) Bug: launchd_core_logic.c:2688 (24132):10 Fri Sep 3 15:59:06 iPhone-de-Jade-Burton com.apple.launchd[1] (UIKitApplication:com.yourcompany.Udp[0xeb7c][5866]) : (UIKitApplication:com.yourcompany.Udp[0xeb7c]) Working around 5020256. Assuming the job crashed. Fri Sep 3 15:59:06 iPhone-de-Jade-Burton com.apple.launchd[1] (UIKitApplication:com.yourcompany.Udp[0xeb7c][5866]) : (UIKitApplication:com.yourcompany.Udp[0xeb7c]) Job appears to have crashed: Segmentation fault
BUG IN MY APP TO DO WITH UNCLEAN SHUT DOWN, NOT RELEVANT RIGHT NOW
Fri Sep 3 15:59:06 iPhone-de-Jade-Burton SpringBoard[39] : Application 'Udp' exited abnormally with signal 11: Segmentation fault Fri Sep 3 16:03:09 iPhone-de-Jade-Burton SpringBoard[39] : Killing com.yourcompany.Udp activate: deactivate: for app installation Fri Sep 3 16:03:11 iPhone-de-Jade-Burton SpringBoard[39] : Reloading and rendering all application icons.
DEBUG SERVER PHONES HOME AGAIN
Fri Sep 3 16:03:18 iPhone-de-Jade-Burton com.apple.debugserver-48[5896] : debugserver-48 for armv6 Copyright (c) 2007-2009 Apple, Inc. All Rights Reserved. Fri Sep 3 16:03:18 iPhone-de-Jade-Burton com.apple.debugserver-48[5896] : Connecting to com.apple.debugserver service... Fri Sep 3 16:03:19 iPhone-de-Jade-Burton kernel[0] : lockbot[5888] Builtin profile: debugserver (sandbox) Fri Sep 3 16:03:20 iPhone-de-Jade-Burton com.apple.launchd[1] (UIKitApplication:com.yourcompany.Udp[0x62c6][5897]) : (UIKitApplication:com.yourcompany.Udp[0x62c6]) Spawned and waiting for the debugger to attach before continuing... Fri Sep 3 16:03:21 iPhone-de-Jade-Burton com.apple.debugserver-48[5896] : Got a connection, waiting for debugger instructions for task "(null)". Fri Sep 3 16:03:21 iPhone-de-Jade-Burton kernel[0] : launchd[5897] Builtin profile: container (sandbox) Fri Sep 3 16:03:21 iPhone-de-Jade-Burton kernel[0] : launchd[5897] Container: /private/var/mobile/Applications/B69449D6-EBC4-41E1-AEB0-8D8C91C7EA17 [69] (sandbox)
I RELAUNCH MY APP; STILL NOT WORKING
Fri Sep 3 16:03:40 iPhone-de-Jade-Burton Udp[5897] : JSplitter sending packets Fri Sep 3 16:03:40 iPhone-de-Jade-Burton Udp[5897] : 16 byte(s), index = 1, group = 0, total = 1 Fri Sep 3 16:03:40 iPhone-de-Jade-Burton Udp[5897] : NOTE: sending group sequence 0 Fri Sep 3 16:03:40 iPhone-de-Jade-Burton Udp[5897] : JResender saved packet. total now: 1 Fri Sep 3 16:03:40 iPhone-de-Jade-Burton Udp[5897] : Socket error 65, No route to host
I QUIT MY APP
Fri Sep 3 16:03:46 iPhone-de-Jade-Burton Udp[5897] : recvfrom returned -1
MORE LAUNCHD "BUG" LOGS
Fri Sep 3 16:03:46 iPhone-de-Jade-Burton com.apple.launchd[1] (UIKitApplication:com.yourcompany.Udp[0x62c6][5897]) : (UIKitApplication:com.yourcompany.Udp[0x62c6]) Bug: launchd_core_logic.c:3270 (24132):0 Fri Sep 3 16:03:46 iPhone-de-Jade-Burton com.apple.debugserver-48[5896] : 1 [1708/1403]: error: ::read ( 6, 0x3809f4, 1024 ) => -1 err = Bad file descriptor (0x00000009) Fri Sep 3 16:03:46 iPhone-de-Jade-Burton com.apple.launchd[1] (UIKitApplication:com.yourcompany.Udp[0x62c6][5897]) : (UIKitApplication:com.yourcompany.Udp[0x62c6]) Bug: launchd_core_logic.c:799 (24132):3 Fri Sep 3 16:03:46 iPhone-de-Jade-Burton com.apple.launchd[1] (UIKitApplication:com.yourcompany.Udp[0x62c6][5897]) : (UIKitApplication:com.yourcompany.Udp[0x62c6]) Bug: launchd_core_logic.c:2688 (24132):10 Fri Sep 3 16:03:46 iPhone-de-Jade-Burton com.apple.launchd[1] (UIKitApplication:com.yourcompany.Udp[0x62c6][5897]) : (UIKitApplication:com.yourcompany.Udp[0x62c6]) Working around 5020256. Assuming the job crashed.
NOW LAUNCHING "Stocks" APP
Fri Sep 3 16:03:46 iPhone-de-Jade-Burton SpringBoard[39] : Unable to delete job with label UIKitApplication:com.yourcompany.Udp[0x62c6]. Error: No such process Fri Sep 3 16:03:53 iPhone-de-Jade-Burton Stocks[5900] : CGImageCreateWithImageProvider: invalid image size: 10 x 10. Fri Sep 3 16:03:53 iPhone-de-Jade-Burton Stocks[5900] : CGImageCreateWithImageProvider: invalid image size: 10 x 10. Fri Sep 3 16:03:53 iPhone-de-Jade-Burton UIKitApplication:com.apple.stocks[0x680e][5900] : Fri Sep 3 16:03:53 iPhone-de-Jade-Burton Stocks[5900] : CGImageCreateWithImageProvider: invalid image size: 10 x 10. Fri Sep 3 16:03:53 iPhone-de-Jade-Burton UIKitApplication:com.apple.stocks[0x680e][5900] : Fri Sep 3 16:03:53 iPhone-de-Jade-Burton Stocks[5900] : CGImageCreateWithImageProvider: invalid image size: 10 x 10. Fri Sep 3 16:03:53 iPhone-de-Jade-Burton configd[24] : CaptiveNetworkSupport:UIAllowedNotifyCallback:70 uiallowed: true
COMMCENTER
Fri Sep 3 16:03:53 iPhone-de-Jade-Burton CommCenter[31] : Client [Stocks] is telling PDP context 0 to go active. Fri Sep 3 16:03:53 iPhone-de-Jade-Burton CommCenter[31] : forcing connection mask for 0 to be internet because there is no mask Fri Sep 3 16:03:53 iPhone-de-Jade-Burton CommCenter[31] : Client [Stocks] is telling PDP context 0 to go active. Fri Sep 3 16:03:53 iPhone-de-Jade-Burton CommCenter[31] : forcing connection mask for 0 to be internet because there is no mask Fri Sep 3 16:03:54 iPhone-de-Jade-Burton CommCenter[31] : Client [Stocks] is telling PDP context 0 to go active. Fri Sep 3 16:03:54 iPhone-de-Jade-Burton CommCenter[31] : forcing connection mask for 0 to be internet because there is no mask Fri Sep 3 16:03:54 iPhone-de-Jade-Burton CommCenter[31] : Client [Stocks] is telling PDP context 0 to go active. Fri Sep 3 16:03:54 iPhone-de-Jade-Burton CommCenter[31] : forcing connection mask for 0 to be internet because there is no mask
CONFIGD
Fri Sep 3 16:03:55 iPhone-de-Jade-Burton configd[24] : .885 (+362.900) SCDynamicStore "network" notification State:/Network/Interface/pdp_ip0/IPv4 : { Addresses : { 0 : 10.165.224.136 } DestAddresses : { 0 : 10.165.224.136 } }
Fri Sep 3 16:03:56 iPhone-de-Jade-Burton configd[24] : CaptiveNetworkSupport:CaptiveHandleNetworkChanged:2158 key: State:/Network/Service/3A1DA52C-9DBD-4573-9463-C4FEFAF18AF6/IPv4 Fri Sep 3 16:03:56 iPhone-de-Jade-Burton kernel[0] : AppleSerialMultiplexer: nif::ioctl: MTU set to 1450 Fri Sep 3 16:03:56 iPhone-de-Jade-Burton configd[24] : network configuration changed.
INTERFACE THAT WAS PREVIOUSLY DISABLED HAS BEEN REACTIVATED? NOTE 3 SECONDS AFTER "Stocks" LAUNCHED
Fri Sep 3 16:03:56 iPhone-de-Jade-Burton CommCenter[31] : Activated PDP context 0 that supports connection types 0x1.
CONFIGD TELLS US ABOUT IT
Fri Sep 3 16:03:56 iPhone-de-Jade-Burton configd[24] : .274 (+0.388) SCDynamicStore "network" notification State:/Network/Service/3A1DA52C-9DBD-4573-9463-C4FEFAF18AF6/IPv4 : { Addresses : { 0 : 10.165.224.136 } InterfaceName : pdp_ip0 NetworkSignature : Cellular WAN: pdp_ip0 Router : 10.165.224.136 SubnetMasks : { 0 : 255.255.255.255 } } State:/Network/Global/DNS State:/Network/Global/IPv4 : { PrimaryInterface : pdp_ip0 PrimaryService : 3A1DA52C-9DBD-4573-9463-C4FEFAF18AF6 Router : 10.165.224.136 }
Fri Sep 3 16:03:56 iPhone-de-Jade-Burton configd[24] : .805 (+0.530) dnsinfo notification Fri Sep 3 16:03:56 iPhone-de-Jade-Burton configd[24] : .862 (+0.057) Primary service: 3A1DA52C-9DBD-4573-9463-C4FEFAF18AF6 (pdp_ip0) Fri Sep 3 16:03:56 iPhone-de-Jade-Burton configd[24] : hostname (prefs) = iPhone-de-Jade-Burton
DEBUGSERVER
Fri Sep 3 16:03:58 iPhone-de-Jade-Burton com.apple.debugserver-48[5905] : debugserver-48 for armv6 Copyright (c) 2007-2009 Apple, Inc. All Rights Reserved. Fri Sep 3 16:03:58 iPhone-de-Jade-Burton com.apple.debugserver-48[5905] : Connecting to com.apple.debugserver service... Fri Sep 3 16:03:58 iPhone-de-Jade-Burton kernel[0] : lockbot[5904] Builtin profile: debugserver (sandbox) Fri Sep 3 16:04:05 iPhone-de-Jade-Burton com.apple.debugserver-48[5906] : debugserver-48 for armv6 Copyright (c) 2007-2009 Apple, Inc. All Rights Reserved. Fri Sep 3 16:04:05 iPhone-de-Jade-Burton com.apple.debugserver-48[5906] : Connecting to com.apple.debugserver service... Fri Sep 3 16:04:05 iPhone-de-Jade-Burton kernel[0] : lockbot[5904] Builtin profile: debugserver (sandbox) Fri Sep 3 16:04:10 iPhone-de-Jade-Burton com.apple.debugserver-48[5907] : debugserver-48 for armv6 Copyright (c) 2007-2009 Apple, Inc. All Rights Reserved. Fri Sep 3 16:04:10 iPhone-de-Jade-Burton com.apple.debugserver-48[5907] : Connecting to com.apple.debugserver service... Fri Sep 3 16:04:10 iPhone-de-Jade-Burton kernel[0] : lockbot[5904] Builtin profile: debugserver (sandbox) Fri Sep 3 16:04:16 iPhone-de-Jade-Burton com.apple.debugserver-48[5908] : debugserver-48 for armv6 Copyright (c) 2007-2009 Apple, Inc. All Rights Reserved. Fri Sep 3 16:04:16 iPhone-de-Jade-Burton com.apple.debugserver-48[5908] : Connecting to com.apple.debugserver service... Fri Sep 3 16:04:16 iPhone-de-Jade-Burton kernel[0] : lockbot[5904] Builtin profile: debugserver (sandbox) Fri Sep 3 16:08:53 iPhone-de-Jade-Burton SpringBoard[39] : MultitouchHID(20af10) uilock state: 0 -> 1 Fri Sep 3 16:08:54 iPhone-de-Jade-Burton configd[24] : CaptiveNetworkSupport:UIAllowedNotifyCallback:70 uiallowed: false
It turns out there is some power management going on that can take down the 3G network interface. The API to bring it back up is Apple private.
This seems to crop up most often when using plain vanilla BSD sockets.
Apple has added some code inside of CFSocketStream to check for traffic and keep the network interface up if traffic is still flowing. If it sees no traffic for a minute or so the network interface can be torn down and the antenna turned off to save power. If you send traffic across the CFSocketStream it should come back up. In the case of UDP, you'll probably have to open a CFSocketStream and send some traffic occasionally in order to keep the interface up.
精彩评论