Request timed out with _kCFStreamErrorCodeKey=60

Hi,


We occasionally get the subject error while downloading using NSURLSession. We set 60 seconds to the NSURLSessionConfiguration.timeoutIntervalForRequest property. But, we get the error in from 12 to 20 seconds. When a response doesn't come for more than 60 seconds, we get another error with _kCFStreamErrorCodeKey=-2102.

I couldn't locate definitions of _kCFStreamErrorCodeKey in headers. Can someone let me know what the error code key is and what the value 60 means?


Thank you,

sukeza

Replies

Error 60 is probably

ETIMEDOUT
, but I can’t say for sure without knowing the error domain. If I’m right, the error domain should be
kCFStreamErrorDomainPOSIX
, or 1.

Error -2102 is

kCFStreamErrorRequestTimeout
, an internal error code in the
kCFStreamErrorDomainHTTP
domain.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Eskimo san


Thank for your reply.

This is the error code we get when request timed out unexpectedly.


Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x60800044a0e0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=60, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=https:/ NSErrorFailingURLKey=https:/ _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=60, NSLocalizedDescription=The request timed out.}}}


So, this is ETIMEDOUT as you write. This means connection failure, am I right?


Thank you,

sukeza

This means connection failure, am I right?

Right. To figure out more than that you’d need one or both of the following diagnostics:

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hi Eskimo!


You seem to be the most active representative here, so let me ask you of something related


I am receiving the ETIMEDOUT when reading an InputStream (swift) after 60 seconds in a polling mode on a serial dispatch queue


Stream.getStreamsToHost(withName: self.address, port: self.port, inputStream: &input, outputStream: &output)
/// ....

/// in input stream
self.open()

let read = buffer.withUnsafeMutableBytes {
    self.read($0.advanced(by: validBufferBytes), maxLength: bufferSize)
}


Now, I'm puzzled, as no documentation hints that this tiemout will happen. It states that the call should block until there are bytes available.

Also, I have searched high and low and it seems that I can't control this timeout.


I have gone as far as querying the SO_RECVTIMEO socket option, but it looks like it's set to 0 as it should by default, meaning no timeout.


What's happening? Can you please point to some authoritative information source on the actual behaviour and ways to control it?

Hi Eskimo,


We are getting similar error for last couple of weeks. Here are the characteristics of the issue.


  • Time out happens with error code, _kCFStreamErrorCodeKey=60.
  • It happens only in LA area and on verizon mobile network. We have tested and it works fine in Denver, Chicago area with same verizon network.
  • When it fails, Request times out even before timeinterval set for the httpsession is reached. Time interval set is 60 seconds
  • Any other networks like T-Mobile and AT&T do not have this issue.
  • Works fine with wifi networks.
  • When we test with poor network simulation, error code we get is _kCFStreamErrorCodeKey=-2102, not _kCFStreamErrorCodeKey=60


finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=\{_kCFStreamErrorCodeKey=60, NSUnderlyingError=0x281d3ba20 \{Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo=\{_kCFStreamErrorCodeKey=60, _kCFStreamErrorDomainKey=1\}\}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <5847334E-8015-405E-9DBF-0B62EBA5E689>.<84>, _NSURLErrorRelatedURLSessionTaskErrorKey=(\

    "LocalDataTask <5847334E-8015-405E-9DBF-0B62EBA5E689>.<84>"\

), NSLocalizedDescription=The request timed out., NSErrorFailingURLStringKey=https://example.com/, NSErrorFailingURLKey=https://example.com/, _kCFStreamErrorDomainKey=1\}\


Please update if any solution is available for the same.

  • Hello! did you solve your problem? Now I have similar error, could you tell how you solved it? thanx

Add a Comment

Hello,

We have the same issue with ios >= 14.7 Did anybody solved it?

Did anybody solved it?

There isn’t a single solution here; there are lots of different causes of this error and that means there are lots of different solutions. To figure out what’s causing this error in your specific environment, you’ll need to deploy some debugging tools. Things have changed a bit since I last posted links to those tools, so here’s the latest:

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"