title: NSURLErrorDomain Code=-1001 error when a http post request is sent
body: <p>I am using the following code to post an image to my server. </p>
  
  <pre><code>@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()
  }
  </code></pre>
  
  <p>where <code>createRequest()</code> creates the required NSURLRequest object. </p>
  
  <p><strong>This works fine when I use a simulator</strong>. The problem is that I am getting the following error when I run my app on an iPhone.</p>
  
  <pre><code>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.)"}
  </code></pre>
  
  <p>I have learned that this error is a timeout error. Restarting the app or phone didn't helped. Moreover I have tried posting an image to my server from a web browser and it worked with no problem. </p>
  
  <p>What might be causing this timeout error?</p>
  
  <p><strong>EDIT:</strong> When I monitor my network activity, I realized the app sends 10 MB data even though the image that I am sending is 0.1 MB.</p>