一种实际上返回了内容却提示请求失败的网络异常案例
遇到一种server请求,内容返回了,但是网络库返回请求失败:
Content-Type: application/json;charset=utf-8
Content-Length: 100
看了下,因为返回的状态是close
Connection: close
image.png
这种到底是什么网络错误呢?
打断点: 发现进入到了NSURLSessionTaskDelegate回调:
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error
error信息
Error Domain=NSURLErrorDomain Code=-1005 "网络连接已中断。" UserInfo=
{_kCFStreamErrorCodeKey=-4,
NSUnderlyingError=0x283a8cc30
{Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)"
UserInfo=
{NSErrorPeerAddressKey=<CFData 0x281660690 [0x1ff36f730]>
{length = 16, capacity = 16, bytes = 0x1002043a7f0000010000000000000000},
_kCFStreamErrorCodeKey=-4,
_kCFStreamErrorDomainKey=4}},
_NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <B40780FD-05EB-4D25-BCA7-ACB8D9C57A72>.<6>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <B40780FD-05EB-4D25-BCA7-ACB8D9C57A72>.<6>"
),
NSLocalizedDescription=网络连接已中断。,
NSErrorFailingURLStringKey=https://xxx.xxxx.com/app/securePhone?id=20122222222&type=0&phone=18888888888&ipAddr=1x.xx.xx.xx, NSErrorFailingURLKey=https://xxxx.xxxx.com/app/securePhone?id=20122222222&type=0&phone=18888888888&ipAddr=1x.xx.xx.xx, _kCFStreamErrorDomainKey=4}
网友评论