0
votes

How to solve this error?

Request failed with error: Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={NSUnderlyingError=0x7fc77b041ce0 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={_kCFStreamErrorCodeKey=-4, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=https://www.themoviedb.org/search/remote/multi?, NSErrorFailingURLKey=https://www.themoviedb.org/search/remote/multi?, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-4, NSLocalizedDescription=The network connection was lost.}

1
"The network connection was lost." is self explanatory. it has nothing with Alamofire. you have trouble with your network connection. both urls from your example works fine and return valid html pageuser3441734
Me too test both urls and return valid html page. How would problem network connection ?mvpu1

1 Answers

0
votes

I was getting the same error after trying to add parameters to a .GET request using Alamofire and Swift 2. I have found several links where the question has been asked, but have not seen any actual answers. Suggestions for other versions of this error with different kCFStreamErrorDomainKeys don't work. This seems to be a bug with the latest version of Alamofire, but as a workaround I was able to get my code working by manually adding the parameters to the url string.

ie - instead of specifying a url of "https://mywebservice.com/api/mycontroller" and adding parameters:["name":"bob"] you could use

https://mywebservice.com/api/mycontroller?name=bob

Of course this gets more difficult if you are passing many parameters.

You can generate a string like that at runtime: "https://mywebservice.com/api/mycontroller?name=" + name