My app can make many network requests & I am scheduling the RxMoyaProvider on a Concurrent scheduler. I run into this error a lot. When this error is hit, there are usually ~200 threads running CFNetworking. My app does not open an files, so I think this is due to the file descriptor on CFNetworking. I found this with a search but it does not help since I can see this even if requests don't fail.
Any idea on how I can debug this?
2016-11-29 19:11:26.652880 MyApp[30635:2458222] [] __nwlog_err_simulate_crash_libsystem libsystem simulate crash unavailable "libsystem_network.dylib: nw_route_get_ifindex :: socket(PF_ROUTE, SOCK_RAW, PF_ROUTE) failed: [24] Too many open files"
2016-11-29 19:11:26.653620 MyApp[30635:2458222] [] nw_route_get_ifindex socket(PF_ROUTE, SOCK_RAW, PF_ROUTE) failed: [24] Too many open files, dumping backtrace:
[x86_64] libnetcore-856.20.4
0 libsystem_network.dylib 0x00000001121e9682 __nw_create_backtrace_string + 123
1 libsystem_network.dylib 0x00000001121de7d1 nw_route_get_ifindex + 774
2 libsystem_network.dylib 0x00000001121f615e nw_path_simulator_get_path_result + 196
3 libsystem_network.dylib 0x00000001121f5eb0 nw_path_create_evaluator_for_endpoint + 289
4 libnetwork.dylib 0x0000000113079de1 nw_endpoint_handler_start + 415
5 libdispatch.dylib 0x0000000111f66980 _dispatch_call_block_and_release + 12
6 libdispatch.dylib 0x0000000111f900cd _dispatch_client_callout + 8
7 libdispatch.dylib 0x0000000111f6de6b _dispatch_queue_serial_drain + 236
8 libdispatch.dylib 0x0000000111f6eb9f _dispatch_queue_invoke + 1073
9 libdispatch.dylib 0x0000000111f713b7 _dispatch_root_queue_drain + 720
10 libdispatch.dylib 0x0000000111f7108b _dispatch_worker_thread3 + 123
11 libsystem_pthread.dylib 0x000000011233f736 _pthread_wqthread + 1299
12 libsystem_pthread.dylib 0x000000011233f211 start_wqthread + 13
Found the issue. I had created a wrapper that creates the provider with specific endpoint closures. Instead of updating the same provider, it was creating a new one every time. This was creating a new socket for every request.
Awesome :tada:
Thanks for sharing how you fixed it, this may be useful to other people 馃憤
Most helpful comment
Found the issue. I had created a wrapper that creates the provider with specific endpoint closures. Instead of updating the same provider, it was creating a new one every time. This was creating a new socket for every request.