Hi, it's been a while but I just wanted to give a quick update on the app and ask a couple questions.
Ever since I changed the shared container access and data sharing mechanism between the targets, app doesn't seem to crash anymore with EXC_BREAKPOINT (SIGTRAP). However, issue with the app not being able to find a server still persists.
Connection 4: received failure notification
Connection 4: failed to connect 12:8, reason 18 446 744 073 709 551 615
Connection 4: encountered error(12:8)
Task <01313C44-8C0D-4B29-8924-AB530B062FB7>.<3> HTTP load failed, 0/0 bytes (error code: 18 446 744 073 709 550 613 [12:8])
Task <01313C44-8C0D-4B29-8924-AB530B062FB7>.<3> finished with error [18 446 744 073 709 550 613] Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={_kCFStreamErrorCodeKey=8, NSUnderlyingError=0x10c64cc50 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8, _NSURLErrorNWResolutionReportKey=Resolved 0 endpoints in 5ms using unknown from cache, _NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0[802.11], ipv4, dns, uses wifi}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <01313C44-8C0D-4B29-8924-AB530B062FB7>.<3>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <01313C44-8C0D-4B29-8924-AB530B062FB7>.<3>"
), NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=https://api_url, NSErrorFailingURLKey=https://api_url, _kCFStreamErrorDomainKey=12}
While investigating the issue, I found a couple articles for Network Extension guides from Apple. I took some advices from those articles regarding networking within the app with added Network Extensions:
have separate URL session configurations for each target
use timeouts for outgoing requests, etc.
But it didn't really change anything
Interesting thing is that before the issue with failed task occurs it prints out session protocols as ["-"], I guess it means that session failed to establish protocols for outgoing request.
Here are examples of URLSession configurations that I use for DNS Proxy Provider and my Main target
/// DNSProxy network service
public final class DNSProxyNetworkService: NSObject, Requestable, URLSessionTaskDelegate {
static let shared = DNSProxyNetworkService()
lazy var session: URLSession = {
let config = URLSessionConfiguration.ephemeral
return URLSession(
configuration: config,
delegate: self,
delegateQueue: nil
)
}()
}
extension DNSProxyNetworkService {
public func urlSession(_ session: URLSession, task: URLSessionTask, didFinishCollecting metrics: URLSessionTaskMetrics) {
let protocols = metrics.transactionMetrics.map { $0.networkProtocolName ?? "-" }
Logger.statistics.debug("[DNSProxyNetworkService] – session protocols: \(protocols, privacy: .public)")
}
}
/// MainTarget network service
public final class MainTargetNetworkService: NSObject, Requestable, URLSessionTaskDelegate {
static let shared = MainTargetNetworkService()
lazy var session: URLSession = {
let config = URLSessionConfiguration.default
return URLSession(
configuration: config,
delegate: self,
delegateQueue: nil
)
}()
}
extension MainTargetNetworkService {
public func urlSession(_ session: URLSession, task: URLSessionTask, didFinishCollecting metrics: URLSessionTaskMetrics) {
let protocols = metrics.transactionMetrics.map { $0.networkProtocolName ?? "-" }
Logger.statistics.debug("[MainTargetNetworkService] – session protocols: \(protocols, privacy: .public)")
}
}
Note: this issue mostly occurs if the build is initiated from Xcode when the device already has app installed or during initial launch for the first build on the device
Would be grateful to hear any advices or suggestions for further investigation of this issue, thank you!