ios - The same URL, why urlsession gets wrong, but using NSURLConnection always succeeds -
let url = url(string: "https://soufunapp.3g.fang.com/http/sf2014.jsp?messagename=usercount&wirelesscode=dd146fd49861797918ada44b7e201180") let task = urlsession.shared.datatask(with: urlrequest(url: url!)) { (data, response, error) in print("always fail") if error != nil { print(error!) } } task.resume() nsurlconnection.sendasynchronousrequest(urlrequest(url: url!), queue: operationqueue.main) { (response, data, error) in print("always succeed") } error domain=nsurlerrordomain code=-1001 "the request timed out." userinfo={nsunderlyingerror=0x60000005ccb0 {error domain=kcferrordomaincfnetwork code=-1001 "(null)" userinfo={_kcfstreamerrorcodekey=-2102, _kcfstreamerrordomainkey=4}}, nserrorfailingurlstringkey= https://soufunapp.3g.fang.com/http/sf2014.jsp?messagename=usercount&wirelesscode=dd146fd49861797918ada44b7e201180 , nserrorfailingurlkey