Request Timed out with Code

最后都变了- 提交于 2021-01-28 07:25:33

问题


Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x608000244a70 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=http://www.dfdd, NSErrorFailingURLKey=http://www.dfdd.com, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}

Am getting this response calling MY API.. am using alamofire to call the api.. Is any problem in alamofire or local API


回答1:


You have to following solution.

  1. Connect with fast internet connection because your request carry heavy data.
  2. Set request timeout to session manager

    manager.session.configuration.timeoutIntervalForRequest = 120




回答2:


The main causes of this issue are either:

  1. The server is under heavy load, or does not have the resources to be able to respond in a timely fashion
  2. The users network connection is slow, and unable to download the response quick enough.

You should check your API & Server logs to look for any potential issues there, ensure there are no errors and that the API is capable of handling your requests as the app scales.

Also, you should add some additional error handling in your application so that if this issue does occur, not only do you handle the case properly and show the user that an error occured (or retry) and also log/report the error so that you can respond to it and investigate.

Sometimes users connections will drop due to loss of mobile signal or other reasons so you need to handle this gracefully.



来源:https://stackoverflow.com/questions/44564422/request-timed-out-with-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!