ios - 错误域=com.alamofire.error.serialization.response 代码=-1011“请求失败 : forbidden (403)

标签 ios swift afnetworking afnetworking-3

我正在使用 AFNetworking 3.1.0 发出 http 请求。 它在我提出请求后显示如下。我提出请求的代码在底部。如果没有 ssl VPN,您可以看到下面的 url 是无法访问的。

Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: forbidden (403)" UserInfo={com.alamofire.serialization.response.error.response= { URL: https://223.71.215.70/web/1/http/0/10.100.5.105:6666/entry } { status code: 403, headers { Connection = "Keep-Alive"; "Content-Length" = 238; "Content-Type" = "text/html; charset=iso-8859-1"; Date = "Wed, 14 Dec 2016 14:27:48 GMT"; "Keep-Alive" = "timeout=15, max=100"; "X-Frame-Options" = SAMEORIGIN; } }, NSErrorFailingURLKey=https://223.71.215.70/web/1/http/0/10.100.5.105:6666/entry, NSLocalizedDescription=Request failed: forbidden (403), com.alamofire.serialization.response.error.data=<3c21444f 43545950 45204854 4d4c2050 55424c49 4320222d 2f2f4945 54462f2f 44544420 48544d4c 20322e30 2f2f454e 223e0a3c 68746d6c 3e3c6865 61643e0a 3c746974 6c653e34 30332046 6f726269 6464656e 3c2f7469 746c653e 0a3c2f68 6561643e 3c626f64 793e0a3c 68313e46 6f726269 6464656e 3c2f6831 3e0a3c70 3e596f75 20646f6e 27742068 61766520 7065726d 69737369 6f6e2074 6f206163 63657373 202f7765 622f312f 68747470 2f302f31 302e3130 302e352e 3130353a 36363636 2f656e74 72790a6f 6e207468 69732073 65727665 722e3c2f 703e0a3c 2f626f64 793e3c2f 68746d6c 3e0a>} Request failed: forbidden (403)

let config = URLSessionConfiguration.default
config.timeoutIntervalForRequest = 30
let manager = AFHTTPSessionManager(sessionConfiguration: config)
manager.requestSerializer = AFHTTPRequestSerializer() // AFJSONRequestSerializer(writingOptions: .prettyPrinted)
manager.responseSerializer = AFHTTPResponseSerializer() // AFJSONResponseSerializer(readingOptions: .mutableContainers)
//      manager.responseSerializer.acceptableContentTypes = ["text/html"]
manager.responseSerializer.acceptableContentTypes = ["application/json", "text/json", "text/JavaScript", "text/html", "text/plain"]
let policy = AFSecurityPolicy(pinningMode: .none)
policy.allowInvalidCertificates = true
policy.validatesDomainName = false
manager.securityPolicy = policy

manager.post(url, parameters: para, progress: nil, success: { (task:URLSessionDataTask, a:Any?) in
            print(123)
        }) { (task: URLSessionDataTask?, error: Error) in
//          print(task?.description)
            print(error)
            print(error.localizedDescription)
        }

最佳答案

我发现如果我的手机时钟不同步...也许可以检查一下您的手机是否设置了正确的时间“自动时区”,看看是否可行...

引用网址:https://community.fitbit.com/t5/Charge-HR/Can-t-set-up-error-Forbidden-403/td-p/1053680

关于ios - 错误域=com.alamofire.error.serialization.response 代码=-1011“请求失败 : forbidden (403),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41145223/

相关文章:

ios - 观察 UINavigationController navigationBar 显示/隐藏

swift - 使用 Swift 3 编写桥接类脚本

ios - 错误域=com.alamofire.error.serialization.response 代码=-1011“请求失败 : bad request (400)

json - 检索 JSON 数据然后解析它(需要一些帮助)

ios - 通过 TableView 编辑核心数据

objective-c - AFNetworking - 为什么它会产生一个网络请求线程?

xcode - 我正在使用AFNetworking收到编译器警告,但事实并非如此。我如何解决它?

ios - 如何从我的 iOS 应用程序在 Facebook 上分享内容?

ios - Keep Alive 在 iOS 上无法正常工作

ios - 使用纬度和经度用 pin 打开 iOS map