title: Swift URLSession.shared.dataTask GET Request -1001 returns timeout
body: <p>Sending a POST request to our NGINX Server works good with <code>URLRequest</code> and <code>URLSession.shared.dataTask</code>.
  I can login to my app but when I try a GET request my server has no log that the request reached him. Finally I get the timeout error. Important, I am using https. I also tried to use http for GET Requests. on my NGINX Server I set TLS to 1.2 only (I am not a system specialist, I did that in the nginx cfg file. </p>
  
  <blockquote>
    <p>Error Domain=NSURLErrorDomain Code=-1001 "Zeitüberschreitung bei der Anforderung." UserInfo={NSUnderlyingError=0x60400005abe0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=<a href="https://myurl" rel="nofollow noreferrer">https://myurl</a>, NSErrorFailingURLKey=<a href="https://myurl" rel="nofollow noreferrer">https://myurl</a>, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=Zeitüberschreitung bei der Anforderung.}</p>
  </blockquote>
  
  <p>I am sure that my code for the <code>URLRequest</code> and <code>URLSession</code> is correct because against localhost and our development environment I do not have any of those problems.</p>
  
  <p>Thats my code to create my <code>URLRequest</code></p>
  
  <pre><code>private func buildUrlRequest(jsonObject:[String: Any], connectionType:ConnectionTypes, url:String) -&gt; NSMutableURLRequest? {
      let jsonDataSerialized:Data
      do {
          jsonDataSerialized = try JSONSerialization.data(withJSONObject: jsonObject)
      } catch {
          return nil
      }
      var request:NSMutableURLRequest
      if nextData {
          request = URLRequest(url: URL(string: self.nextRequestPage)!) as! NSMutableURLRequest
      } else {
          let tString = self.mBaseUrl + url
          if let encoded = tString.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed),
              var finalurl = URL(string: encoded)
          {
              if connectionType == .GET {
                  var tString:String
                  tString=finalurl.absoluteString
                  tString = tString.replacingOccurrences(of: "https", with: "http")
                  finalurl = URL(string:tString)!
              }
              request = URLRequest(url: finalurl) as! NSMutableURLRequest
          } else {
              return nil
          }
      }
      request.httpMethod = connectionType.rawValue // i am using enum here
      request.setValue("application/json", forHTTPHeaderField: "Content-Type")
      request.setValue("no-cache)", forHTTPHeaderField: "Cache-Control")
      request.httpBody = jsonDataSerialized
      if mUser != nil &amp;&amp; mUser.getSessionId() != nil {
          request.addValue("Token " + mUser.getSessionId()!, forHTTPHeaderField: "Authorization")
      }
      request.cachePolicy = .reloadIgnoringLocalAndRemoteCacheData
      request.timeoutInterval = 30.0
      return request
  }
  </code></pre>
  
  <p>This is how I create the task... after the method body I am using <code>task.resume()</code></p>
  
  <pre><code>let task = URLSession.shared.dataTask(with: request as URLRequest) { data, response, error in .... (and so on)
  </code></pre>
  
  <p>I spend more than hours to solve this problem... But I have no idea.
  I am not sure if the Problem is the Server Config or the Swift code...</p>