Error NSURLErrorDomain = = 1001 when sending a mailing request

I am using the following code to host an image on my server.

@IBAction func postButtonPressed(sender: UIButton) {
    let task = NSURLSession.sharedSession().dataTaskWithRequest(createRequest("http://xx.xx.xxx.xxx/xxxx/"), completionHandler: {
        data, response, error in
        println(NSString(data: data, encoding: NSUTF8StringEncoding))
    })
    task.resume()
}

where createRequest()creates the necessary NSURLRequest object.

This works great when I use the simulator . The problem is that I get the following error when launching the application on the iPhone.

Error Domain=NSURLErrorDomain Code=-1001 "The operation couldn’t be completed. (NSURLErrorDomain error -1001.)" UserInfo=0x155e71f0 {NSErrorFailingURLKey=http://xx.xxx.xxx.xxx/xxxx/, NSErrorFailingURLStringKey=http://54.148.156.117/query/, NSUnderlyingError=0x155674d0 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1001.)"}

I found out that this error is a timeout error. Restarting the application or phone did not help. In addition, I tried to host the image on my server from a web browser, and it worked without problems.

What can cause this timeout error?

The EDIT: . When I track activity on the network, I realized that the application is sending 10 MB of data, although the image I'm sending is 0.1 MB.

+4
3

-, - , , . , .

, NSURLErrorDomain Code=-1001 , :

, .

+2
+2

, , . , URL- .
URL-, , .
, , .

+1
source

All Articles