美文网首页
MacOS开发网络请求:NSURLErrorDomain Cod

MacOS开发网络请求:NSURLErrorDomain Cod

作者: 路漫漫其修远兮Wzt | 来源:发表于2019-12-16 15:39 被阅读0次

    参考资料:https://stackoverflow.com/questions/46971824/network-requests-are-failing-nsurlsession-app-sandbox-xcode-9

    MacOS开发发送网络将请求时,控制台打印错误日志:

    Task <6CDE66EA-DE56-4200-B7A2-7E50C82850A5>.<1> finished with error - code: -1003
    2019-12-16 15:26:02.613888+0800 WztMacTools[96017:526372] Task <6CDE66EA-DE56-4200-B7A2-7E50C82850A5>.<1> load failed with error Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={_kCFStreamErrorCodeKey=-72000, NSUnderlyingError=0x600000c94030 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorCodeKey=-72000, _kCFStreamErrorDomainKey=10}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <6CDE66EA-DE56-4200-B7A2-7E50C82850A5>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
        "LocalDataTask <6CDE66EA-DE56-4200-B7A2-7E50C82850A5>.<1>"
    ), NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=https://*******.com/v1/passport/login, NSErrorFailingURLKey=https://******.com/v1/passport/login, _kCFStreamErrorDomainKey=10} [-1003]
    

    解决方法:
    以下转载自: macApp开发碰到的坑
    mac软件联网问题:
    反正都是用的同一个接口.但是返回的数据在mac上从URLSession中正常返回data变成了返回error.然后控制台打出了底下一堆的东西.(我把时间戳和工程名那部分都截走了.没啥必要看).

    dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
    dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
    dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
    dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:11 Err:-1 Errno:1 Operation not permitted
    2018-03-22 16:06:02.771111+0800 RecordNumberSearch[46980:12407372] [] nw_resolver_create_dns_service_locked DNSServiceCreateDelegateConnection failed: ServiceNotRunning(-65563)
    TIC TCP Conn Failed [1:0x604000169fc0]: 10:-72000 Err(-65563)
    Task <A783272C-620A-4B95-986C-12F2EF8F1096>.<1> HTTP load failed (error code: -1003 [10:-72000])
    Task <A783272C-620A-4B95-986C-12F2EF8F1096>.<1> finished with error - code: -1003
    

    看到HTTP Load failed我还以为是ATS没配的问题.然后配了之后突然想起来,我用的不是https的接口么.那么可能是接口的问题…忙活半天之后发现.只需要进行如下改动就行


    2018032216182648.png

    重新command + r编译运行即可.

    相关文章

      网友评论

          本文标题:MacOS开发网络请求:NSURLErrorDomain Cod

          本文链接:https://www.haomeiwen.com/subject/kvldnctx.html