Hi Apple Engineers,
We are making an iOS app which uses NSURLSession for network communication. To provide enterprise customer the ability to monitor network traffic, we want to support proxy settings inside our app. So, we take advantage of the connectionProxyDictionary property of NSURLSessionConfiguration.
We set the kCFNetworkProxiesProxyAutoConfigURLString key, and expect requests that are scripted to be proxied to either go through the proxy or fail when proxy is not reachable. This is necessary because we don't want requests to go out without being monitored. But during development we noticed that when proxy server is not reachable, requests don't always fail with kCFErrorHTTPProxyConnectionFailure or kCFErrorHTTPSProxyConnectionFailure (CFNetworkError 306 and 310).
More specifically, the behavior we observed are as follows:
- PAC URL resolution timeout: Task failed with 306/310
- PAC URL resolution error: Task bypassed proxy and succeeded
- PAC file download timeout: Task failed with 306/310
- PAC file download error: Task bypassed proxy and succeeded
- PAC file parse error: Task bypassed proxy and succeeded
- Proxy server connection timeout: Task failed with 306/310
- Proxy server connection error: Task bypassed proxy and succeeded
The inconsistency of error handling behavior is confusing, is this a bug? If not, is there a way to configure NSURLSession to always yield error without bypassing the proxy when any of the above happens?