CFNetwork internal error

I'm fetching data using


NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"myurl"]];
self.connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO];
[self.connection start];


and the implementation of NSURLConnectionDelegate and NSURLConnectionDataDelegate. Everything is working fine, but the console gets filled with the following messages:


2015-06-23 10:05:47.927 MyApp[11290:5755832] 11290: CFNetwork internal error (0xc01a:/SourceCache/CFNetwork/CFNetwork-711.3.18/Connection/URLConnectionClient.cpp:780)


Am I missing something?


Xcode 6.3.1 (6D1002) and Deployment Target iOS 8.3.

Replies

In general CFNetwork internal errors are just that, internal errors. The standard response is to file a bug describing the error. It'd be best if you included a small test project that illustrates the problem, hopefully pointing at a test server that reproduces the problem. If the relevant server isn't public, you should include a packet trace and a CFNetwork diagnostics log.

If you do file a bug, please post your bug number here, just for the record.

Is the error accompanied by an actual failure? That is, does the request work and you just get this error message? If so, it's reasonable to just ignore it.

Finally, the error seems to be associated with how CFNetwork handles multipart/x-mixed-replace content. In general CFNetwork handles that reasonable well. Are you sure that your server is generated correctly formed multipart/x-mixed-replace content?

Share and Enjoy

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

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

Thanks for the explanation. This is a project where I grab a squence of MJPEG images form a http://www.vivotek.com/vs8102/ video server. As each image arrives in connection:didRecieveResponse:, I just update a UIImageView with the new image data. Everything is working really well, the error is not accompanied by an actual failure except for one thing: after running the app for about 5 minutes it crashes after showing "Received memory warning" in the console. But I don't know if that crash is really related to the CFNetwork internal error message or not.

"Received memory warning" is one of those "The crash is your fault, unless you can prove otherwise" warning messages. :-)


Generally, it's from things like attempting to hold an entire sequence of files in memory at the same time (or trying to append data to an NSMutableData in memory instead of appending the data directly to a temporary file).

Hello eskimo,


I have the same problem. The iOS framework has memory leaks when we open a video stream through http.

I already try many workaround to try to avoid this memory leak without success. Please see my code:


[[NSURLCache sharedURLCache] setMemoryCapacity:0];
[[NSURLCache sharedURLCache] setDiskCapacity:0];

_connection = [[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithURL:_url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:20.0]
                                                      delegate:self];


We can just leave the didReceiveData without code,

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {

}


and still verify the memory leak in XCode, because the allocated memory don't stop to increase, and in Instruments, because "Leaks" reports many Leaked Objects at libsystem_c.dylib reallocf


Also, it seams that the number of leaked bytes per second increase with time. For the first frames, the instruments detect 200 KB of leaks per second (remember we are receiving MJPEG video)...and after 30 seconds is detecting 2000 KB of leaks per second.


Do you know some workaround that we can use? We need to fix this soon for our customers. Please help,

Thank you,

Nelson Ramos

Try profiling your code and seeing what types of objects are leaking. Then, see if there's some way to use NSURLConnection that doesn't cause it to use that part of the software. For example, if the caching system is leaking, try disabling caching.


Also, make sure your delegate methods are all implemented correctly. IIRC, there are some that require you to call methods on challenge sender and other such curiosities, and if you fail to call the callbacks, it will leak like a sieve. Or maybe I'm thinking of the completion handlers in NSURLSession. Either way, you get the point. 🙂

Does this problem occur with NSURLSession? If so, you should file a bug about it. Ideally your bug report should include:

  • a small test project that demonstrates the issue

  • the URL of a camera available on the public Internet

Apropos the second point, if you have a publicly accessible camera that reproduces the problem please post its URL (or email it to me if you don't want to share it with everyone; my address is in my signature). I'd like to take a quick look at this, just to verify my own expectations.

Finally, please post your bug number, just for the record.

Share and Enjoy

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

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

Have you found a solution for the problem? Have exact the same problem with a Vivotek VS8100

Have you found a solution for the problem? We are also facing this issue with MJPEG feed.