kean kean - 1 year ago 91
Objective-C Question

NSURLSession task cancellation issue (CFNetwork internal error)

I'm receiving error messages in log:

CFNetwork internal error 0xc01a:/SourceCache/CFNetwork/CFNetwork-711.1.16/Connection/URLConnectionLoader.cpp:1321)

The problem is something to deal with cancellation of
objects under extreme pressure (tasks are created and cancelled very fast). The error doesn't occur when tasks aren't cancelled. And it's also doesn't occur when tasks are cancelled with a delay:

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[_task cancel];

Apple has stopped providing a CFNetwork source a long time ago. How someone go about debugging this kind of error?

Answer Source

There is a simple solution to this problem - you should rate limit the requests. URLSession just isn't designed to be used like that.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download