本地服务器上的URLSession错误-1009
我需要使用HTTPS协议从硬件设备中获取数据。设备的IP地址为 192.168.4.1 ,当我使用该设备的设备连接到计算机上的热点时,便在Postman上调用GET请求https://192.168.4.1/scanlist,作为响应返回JSON数据。但是,当我使用iPhone连接设备热点并且尝试在iPhone上执行相同的GET请求时,出现URLSession错误-1009。
guard let url = URL(string: "https://192.168.4.1/scanlist") else {return}
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in
guard let dataResponse = data,
error == nil else {
print(error?.localizedDescription ?? "Response Error")
return }
do{
//here dataResponse received from a network request
let jsonResponse = try JSONSerialization.jsonObject(with:
dataResponse, options: [])
print(jsonResponse) //Response result
guard let jsonArray = jsonResponse as? [ScanList] else {
return
}
for dic in jsonArray{
self.ssidListArr.append(dic)
}
if self.ssidListArr.count > 0{
self.popUpView.isHidden = false
// populate tableview
}
} catch let parsingError {
print("Error", parsingError)
}
}
task.resume()
'''
我遇到错误:
Error Domain = NSURLErrorDomain代码= -1009“ Internet连接似乎已脱机。
我的信息列表:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<key>192.168.4.1</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
<!-- Optional: Specify minimum TLS version -->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
<key>NSRequiresCertificateTransparency</key>
<false/>
</dict>
</dict>
</dict>