React Native bundle 加载缓慢或根本不加载
React Native bundle loading slowly or not at all
问题似乎是特定于网络的,控制台日志指向两个可能导致速度下降的错误:
nw_resolver_create_dns_service_locked [C150094]
DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
或
nw_socket_handle_socket_event Socket SO_ERROR [61:
Connection refused]
我尝试了两种网络配置:
- 开发 Mac 和 iPhone 在大型公司网络的同一子网 (WiFi) 上 - JS 包加载缓慢或根本不加载
- 开发 Mac(WiFi 热点)和 iPhone 之间的直接连接 - JS 包加载速度非常快
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 }')
fi
echo "$IP" > "$DEST/ip.txt"
fi
网络接口:
$ 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
控制台日志:
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]
稍后...
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]
稍后...
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]
稍后...
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]
使用 RN 0.60+
更新:react-native-xcode.sh
中的自定义设置在 运行 pod install
时被覆盖。
问题是我的 Mac 同时连接到 WiFi 和以太网(en0
、en8
和 en9
都在使用中) . RCTBundleURLProvider
将 en0
作为默认值,这导致了一些奇怪的重定向。
我猜 React Native 还不支持多网络接口,所以我最终修改 AppDelegate.m
为正确的 IP。这种方法的问题是IP变化:
#ifdef DEBUG
jsCodeLocation = [NSURL URLWithString:@"http://<en8-IP-address>:8081/index.bundle?platform=ios"];
#else
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
#endif
更好的选择是在 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
问题似乎是特定于网络的,控制台日志指向两个可能导致速度下降的错误:
nw_resolver_create_dns_service_locked [C150094] DNSServiceCreateDelegateConnection failed: NoMemory(-65539)
或
nw_socket_handle_socket_event Socket SO_ERROR [61: Connection refused]
我尝试了两种网络配置:
- 开发 Mac 和 iPhone 在大型公司网络的同一子网 (WiFi) 上 - JS 包加载缓慢或根本不加载
- 开发 Mac(WiFi 热点)和 iPhone 之间的直接连接 - JS 包加载速度非常快
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 }')
fi
echo "$IP" > "$DEST/ip.txt"
fi
网络接口:
$ 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
控制台日志:
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]
稍后...
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]
稍后...
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]
稍后...
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]
使用 RN 0.60+
更新:react-native-xcode.sh
中的自定义设置在 运行 pod install
时被覆盖。
问题是我的 Mac 同时连接到 WiFi 和以太网(en0
、en8
和 en9
都在使用中) . RCTBundleURLProvider
将 en0
作为默认值,这导致了一些奇怪的重定向。
我猜 React Native 还不支持多网络接口,所以我最终修改 AppDelegate.m
为正确的 IP。这种方法的问题是IP变化:
#ifdef DEBUG
jsCodeLocation = [NSURL URLWithString:@"http://<en8-IP-address>:8081/index.bundle?platform=ios"];
#else
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
#endif
更好的选择是在 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