title: NSURLErrorDomain Code=-1004 for few seconds after app start up
body: <p>I'm getting "NSURLErrorDomain Code=-1004" error with Alamofire API calls,
  but <strong>only for few seconds after app started</strong> (or took a rest for few minutes while the app's opened and make a call after that)</p>
  
  <p>If I try to make the same call after few seconds, everything works fine.
  I searched all the Stack Overflow questions and checked all the possible causes below:</p>
  
  <ol>
  <li>No problem with Internet connection</li>
  <li>"App Transport Security Settings" are correct and server's using https (I also tried "NSAllowsArbitraryLoads=true" but that didn't help)</li>
  <li>APIs working fine</li>
  </ol>
  
  <p>My gut feeling is that getting the network settings takes few seconds and when I make an API call before that's done, it just fails immediately. OR.. I'm using a Websocket in background that could be related?</p>
  
  <blockquote>
    <p>FAILURE: Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={NSUnderlyingError=0x137d39380 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={NSErrorPeerAddressKey={length = 16, capacity = 16, bytes = 0x100201bb341a9f540000000000000000}, _kCFStreamErrorCodeKey=-2200, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=[FILTERED], NSErrorFailingURLKey=[FILTERED], _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2200, NSLocalizedDescription=Could not connect to the server.}</p>
  </blockquote>
  
  <p>Any suggestions?</p>
  
  <p><strong><em>UPDATED</em></strong></p>
  
  <p>Found that app makes 4 requests on launch, and 1 or 2 of them randomly fails, and I checked Nginx access and error log and there's no log for the failed calls at all.</p>