React Native bundle loading slowly or not at all

0

The problem seems to be network-specific, the console log points to two possible errors causing the slowdown:

nw_resolver_create_dns_service_locked [C150094] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)

or

nw_socket_handle_socket_event Socket SO_ERROR [61: Connection refused]

I tried two network configurations:

  1. The development Mac and the iPhone on the same subnet (WiFi) of a larger corporate network - JS bundle loads slowly or not at all
  2. Direct connection between the development Mac (WiFi hotspot) and the iPhone - JS bundle loads very fast

AppDelegate.m

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

/node_modules/react-native/scripts/react-native-xcode.sh:

# Enables iOS devices to get the IP address of the machine running Metro Bundler
if [[ "$CONFIGURATION" = *Debug* && ! "$PLATFORM_NAME" == *simulator ]]; then
  IP=$(ipconfig getifaddr en0)
  if [ -z "$IP" ]; then
    IP=$(ifconfig | grep 'inet ' | grep -v ' 127.' | cut -d\   -f2  | awk 'NR==1{print $1}')
  fi

  echo "$IP" > "$DEST/ip.txt"
fi

Network interfaces:

$ ifconfig | grep 'inet '
inet 127.0.0.1 netmask 0xff000000 <- Localhost
inet xxx.xxx.xxx.xxx netmask 0xfffff800 broadcast 10.10.7.255 <- Cable (en0)
inet yyy.yyy.yyy.yyy netmask 0xfffff800 broadcast 10.10.55.255 <- Wireless (en1)
inet 169.254.174.6 netmask 0xffff0000 broadcast 169.254.255.255 <- RN Packager

Console log:

error   17:09:36.741707+0100    MyApp   nw_resolver_create_dns_service_locked [C29701] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:36.743554+0100    MyApp   nw_resolver_create_dns_service_locked [C29702] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:36.745285+0100    MyApp   nw_resolver_create_dns_service_locked [C29703] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:36.745877+0100    MyApp   nw_resolver_create_dns_service_locked [C29704] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:36.747514+0100    MyApp   nw_resolver_create_dns_service_locked [C29705] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:36.748616+0100    MyApp   nw_resolver_create_dns_service_locked [C29714] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:36.749197+0100    MyApp   nw_resolver_create_dns_service_locked [C29715] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:36.750118+0100    MyApp   nw_resolver_create_dns_service_locked [C29716] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:36.751705+0100    MyApp   nw_resolver_create_dns_service_locked [C29717] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:36.752599+0100    MyApp   nw_resolver_create_dns_service_locked [C29718] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:36.753707+0100    MyApp   nw_resolver_create_dns_service_locked [C29719] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.257411+0100    MyApp   nw_resolver_create_dns_service_locked [C29725] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.258018+0100    MyApp   nw_resolver_create_dns_service_locked [C29731] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.258969+0100    MyApp   nw_resolver_create_dns_service_locked [C29732] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.259757+0100    MyApp   nw_resolver_create_dns_service_locked [C29733] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.261023+0100    MyApp   nw_resolver_create_dns_service_locked [C29734] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.261598+0100    MyApp   nw_resolver_create_dns_service_locked [C29735] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.263278+0100    MyApp   nw_resolver_create_dns_service_locked [C29736] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.264353+0100    MyApp   nw_resolver_create_dns_service_locked [C29737] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.265340+0100    MyApp   nw_resolver_create_dns_service_locked [C29745] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.265913+0100    MyApp   nw_resolver_create_dns_service_locked [C29746] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.266989+0100    MyApp   nw_resolver_create_dns_service_locked [C29747] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.267868+0100    MyApp   nw_resolver_create_dns_service_locked [C29748] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.269294+0100    MyApp   nw_resolver_create_dns_service_locked [C29749] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.270294+0100    MyApp   nw_resolver_create_dns_service_locked [C29750] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.271071+0100    MyApp   nw_resolver_create_dns_service_locked [C29751] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.271384+0100    MyApp   nw_resolver_create_dns_service_locked [C29758] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.271955+0100    MyApp   nw_resolver_create_dns_service_locked [C29759] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.273083+0100    MyApp   nw_resolver_create_dns_service_locked [C29760] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.273659+0100    MyApp   nw_resolver_create_dns_service_locked [C29761] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.274663+0100    MyApp   nw_resolver_create_dns_service_locked [C29762] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.275233+0100    MyApp   nw_resolver_create_dns_service_locked [C29763] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.275813+0100    MyApp   nw_resolver_create_dns_service_locked [C29764] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.276921+0100    MyApp   nw_resolver_create_dns_service_locked [C29765] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.278096+0100    MyApp   nw_resolver_create_dns_service_locked [C29766] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.278948+0100    MyApp   nw_resolver_create_dns_service_locked [C29775] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.280069+0100    MyApp   nw_resolver_create_dns_service_locked [C29776] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.281327+0100    MyApp   nw_resolver_create_dns_service_locked [C29777] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.282205+0100    MyApp   nw_resolver_create_dns_service_locked [C29778] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.282999+0100    MyApp   nw_resolver_create_dns_service_locked [C29779] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.283580+0100    MyApp   nw_resolver_create_dns_service_locked [C29780] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.284501+0100    MyApp   nw_resolver_create_dns_service_locked [C29781] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.286073+0100    MyApp   nw_resolver_create_dns_service_locked [C29788] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.286667+0100    MyApp   nw_resolver_create_dns_service_locked [C29789] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.287760+0100    MyApp   nw_resolver_create_dns_service_locked [C29790] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.288697+0100    MyApp   nw_resolver_create_dns_service_locked [C29791] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.289472+0100    MyApp   nw_resolver_create_dns_service_locked [C29792] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.290365+0100    MyApp   nw_resolver_create_dns_service_locked [C29793] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.291999+0100    MyApp   nw_resolver_create_dns_service_locked [C29801] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.293474+0100    MyApp   nw_resolver_create_dns_service_locked [C29802] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.294349+0100    MyApp   nw_resolver_create_dns_service_locked [C29803] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.295423+0100    MyApp   nw_resolver_create_dns_service_locked [C29804] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.297020+0100    MyApp   nw_resolver_create_dns_service_locked [C29805] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.297929+0100    MyApp   nw_resolver_create_dns_service_locked [C29806] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.299973+0100    MyApp   nw_resolver_create_dns_service_locked [C29814] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.300942+0100    MyApp   nw_resolver_create_dns_service_locked [C29815] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.301518+0100    MyApp   nw_resolver_create_dns_service_locked [C29816] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.303319+0100    MyApp   nw_resolver_create_dns_service_locked [C29817] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.304447+0100    MyApp   nw_resolver_create_dns_service_locked [C29818] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.374444+0100    MyApp   nw_connection_get_connected_socket [C29819] Client called nw_connection_get_connected_socket on unconnected nw_connection
error   17:09:37.374644+0100    MyApp   TCP Conn 0x2817b6a00 Failed : error 0:-65539 [-65539]
error   17:09:37.375264+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.375571+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.375977+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.376354+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.376669+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.376986+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.377598+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.378521+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.379112+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.379523+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.379827+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]

Later...

error   17:09:37.560003+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.580106+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.580409+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.580713+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.581020+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.581325+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.581624+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.581927+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.662981+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.663283+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.663631+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.664028+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.664376+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.664755+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.665090+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.665432+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.665777+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.666107+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.666439+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.743908+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.799060+0100    MyApp   nw_resolver_create_dns_service_locked [C29857] DNSServiceGetAddrInfo failed: Unknown(-65537)
error   17:09:37.799824+0100    MyApp   nw_resolver_create_dns_service_locked [C29858] DNSServiceGetAddrInfo failed: Unknown(-65537)
error   17:09:37.800467+0100    MyApp   nw_resolver_create_dns_service_locked [C29859] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.801033+0100    MyApp   nw_resolver_create_dns_service_locked [C29860] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.801603+0100    MyApp   nw_resolver_create_dns_service_locked [C29861] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.802180+0100    MyApp   nw_resolver_create_dns_service_locked [C29862] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.802745+0100    MyApp   nw_resolver_create_dns_service_locked [C29863] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.803313+0100    MyApp   nw_resolver_create_dns_service_locked [C29864] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.804091+0100    MyApp   nw_resolver_create_dns_service_locked [C29874] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.804668+0100    MyApp   nw_resolver_create_dns_service_locked [C29875] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.805233+0100    MyApp   nw_resolver_create_dns_service_locked [C29876] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.805802+0100    MyApp   nw_resolver_create_dns_service_locked [C29877] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.806370+0100    MyApp   nw_resolver_create_dns_service_locked [C29878] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.806932+0100    MyApp   nw_resolver_create_dns_service_locked [C29879] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.807502+0100    MyApp   nw_resolver_create_dns_service_locked [C29880] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.808068+0100    MyApp   nw_resolver_create_dns_service_locked [C29881] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.808645+0100    MyApp   nw_resolver_create_dns_service_locked [C29882] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.809211+0100    MyApp   nw_resolver_create_dns_service_locked [C29883] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.809777+0100    MyApp   nw_resolver_create_dns_service_locked [C29884] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.810345+0100    MyApp   nw_resolver_create_dns_service_locked [C29885] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.901485+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.901839+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.902196+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.902527+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.902852+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.903191+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.903529+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.903848+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.904181+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.904510+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.904864+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.905194+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.905538+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.905893+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.906202+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.906529+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.906866+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.912981+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.918026+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:37.929966+0100    MyApp   nw_resolver_create_dns_service_locked [C29902] DNSServiceGetAddrInfo failed: Unknown(-65537)
error   17:09:37.930722+0100    MyApp   nw_resolver_create_dns_service_locked [C29903] DNSServiceGetAddrInfo failed: Unknown(-65537)
error   17:09:37.931337+0100    MyApp   nw_resolver_create_dns_service_locked [C29904] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.931911+0100    MyApp   nw_resolver_create_dns_service_locked [C29905] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.932475+0100    MyApp   nw_resolver_create_dns_service_locked [C29906] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.933039+0100    MyApp   nw_resolver_create_dns_service_locked [C29907] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.933240+0100    MyApp   nw_resolver_create_dns_service_locked [C29914] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.933819+0100    MyApp   nw_resolver_create_dns_service_locked [C29915] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.934386+0100    MyApp   nw_resolver_create_dns_service_locked [C29916] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.934966+0100    MyApp   nw_resolver_create_dns_service_locked [C29917] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.935533+0100    MyApp   nw_resolver_create_dns_service_locked [C29918] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.936104+0100    MyApp   nw_resolver_create_dns_service_locked [C29919] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.936665+0100    MyApp   nw_resolver_create_dns_service_locked [C29920] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.937233+0100    MyApp   nw_resolver_create_dns_service_locked [C29921] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.937805+0100    MyApp   nw_resolver_create_dns_service_locked [C29922] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
error   17:09:37.945795+0100    MyApp   nw_connection_get_connected_socket [C29922] Client called nw_connection_get_connected_socket on unconnected nw_connection
error   17:09:38.999588+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:38.999922+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:09:38.000298+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]

Later...

error   17:10:30.563154+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:30.563445+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:30.563740+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:30.564030+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:30.564331+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:30.564630+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:30.564924+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:31.898529+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:32.144762+0100    MyApp   nw_socket_connect [C35257.1:1] connectx(16, [srcif=0, srcaddr=<private>, dstaddr=<private>], SAE_ASSOCID_ANY, 0, NULL, 0, NULL, SAE_CONNID_ANY) failed: [61: Connection refused]
error   17:10:32.144828+0100    MyApp   nw_socket_connect <private> connectx failed (fd 16) [61: Connection refused]
error   17:10:32.144884+0100    MyApp   nw_socket_connect connectx failed [61: Connection refused]
error   17:10:32.153072+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:32.153362+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:32.153783+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:32.155424+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:32.156145+0100    MyApp   nw_connection_get_connected_socket [C35259] Client called nw_connection_get_connected_socket on unconnected nw_connection
error   17:10:32.156346+0100    MyApp   TCP Conn 0x2817bd440 Failed : error 0:61 [61]
error   17:10:33.271516+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:33.272726+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:33.278913+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:33.285942+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]

Later...

error   17:10:34.096239+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:34.096532+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:34.096827+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:34.097116+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:34.097414+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:34.097708+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:34.098004+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:35.816966+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:35.817272+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.050535+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.051439+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.051804+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.052109+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.052398+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.052694+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.052989+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.053281+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.053576+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.053900+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.054222+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.054553+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.054884+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.055226+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.055583+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.055923+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.056241+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.056566+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.056895+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.057221+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.057526+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.057820+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.058268+0100    MyApp   nw_socket_handle_socket_event <private> Socket SO_ERROR [61: Connection refused]
error   17:10:36.058896+0100    MyApp   nw_connection_get_connected_socket [C35675] Client called nw_connection_get_connected_socket on unconnected nw_connection
error   17:10:36.059063+0100    MyApp   TCP Conn 0x2818da4c0 Failed : error 0:61 [61]
error   17:10:36.167032+0100    MyApp   nw_socket_connect [C35676.1:1] connectx(16, [srcif=0, srcaddr=<private>, dstaddr=<private>], SAE_ASSOCID_ANY, 0, NULL, 0, NULL, SAE_CONNID_ANY) failed: [61: Connection refused]
error   17:10:36.167088+0100    MyApp   nw_socket_connect <private> connectx failed (fd 16) [61: Connection refused]
error   17:10:36.167164+0100    MyApp   nw_socket_connect connectx failed [61: Connection refused]
ios
react-native
sockets
dns
node-webkit
asked on Stack Overflow Nov 27, 2019 by Peter G. • edited Nov 28, 2019 by Peter G.

1 Answer

0

Update with RN 0.60+: Custom settings in react-native-xcode.sh get overwritten when running pod install.

The problem was that my Mac was connected to both WiFi and ethernet at the same time (en0, en8, and en9 were all in use). RCTBundleURLProvider was taking the en0 as default one and it was causing some weird redirections.

I guess React Native does not support multiple network interfaces yet, so I ended up modifying AppDelegate.m with the correct IP. The problem with this approach is that the IP changes:

#ifdef DEBUG
jsCodeLocation = [NSURL URLWithString:@"http://<en8-IP-address>:8081/index.bundle?platform=ios"];
#else
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
#endif

A better alternative would be to fix it in the packager itself inside react-native-xcode.sh:

# Enables iOS devices to get the IP address of the machine running Metro Bundler
if [[ "$CONFIGURATION" = *Debug* && ! "$PLATFORM_NAME" == *simulator ]]; then
  IP=$(ifconfig | grep 'inet ' | grep -v ' 127.' | cut -d\   -f2  | grep '169.254.')

  echo "$IP" > "$DEST/ip.txt"
fi
answered on Stack Overflow Nov 27, 2019 by Peter G. • edited Mar 6, 2020 by Peter G.

User contributions licensed under CC BY-SA 3.0