I'm using Alamofire in my project for networking. I need to extract data about the protocols used on the device from the requests, specifically the SSL encryption protocol type and the HTTP protocol type.
I'm utilizing Alamofire's API, which internally works with NSURLSessionTaskDelegate (specifically the URLSession:task:didFinishCollectingMetrics method) to access URLSessionTaskTransactionMetrics, which should contain these values. However, I consistently find these fields to be empty, despite their presence being confirmed through Proxyman.
Here's a general overview of the code I'm using. Can anyone suggest what the issue might be? Or perhaps you know of other ways to obtain this data?
class AlamofireNetworkProvider {
private let additionalHeaders: NetworkDefaultHeaders?
private var session: Session
let monitor: ClosureEventMonitor = {
let monitor = ClosureEventMonitor()
monitor.taskDidFinishCollectingMetrics = { session, task, metrics in
metrics.transactionMetrics.forEach { metric in
// do something with the metrics (URLSessionTaskMetrics)
print(metric.negotiatedTLSProtocolVersion)
print(metric.networkProtocolName)
}
}
return monitor
}()
init(additionalHeaders: NetworkDefaultHeaders?) {
self.additionalHeaders = additionalHeaders
self.session = Session(interceptor: ConnectionLostRetryPolicy(), eventMonitors: [monitor])
}
// Executes network requests using Alamofire...
}
Alamofire version: '5.7.1' Min supported iOS version: 15