Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

purgeIdleCellConnections

Tags:

ios

About the "duplicate" state of this question:
This question here was asked in Nov 2012, it contains a detailed description of the problem and has 3 answers.
The question referred to as "original" was asked in Feb 2013 (3 month after this "duplicate"), has no detailed description and only 2 answers. The best of its two answers is just a link-only-answer.


Why do I get this message in my console?:

purgeIdleCellConnections: found one to purge conn = (some object-ID)

When my App starts I send a message to my server. I do this with this lines of code:

@implementation AppStatus {
    NSMutableData*   activeDownload;
    NSURLConnection* Connection;
}

- (id) init {
    self = [super init];
    if (self) {
        activeDownload = nil;
        Connection     = nil;
    }
    return self;
}

- (void)sendStatus:(NSString*)url {
    NSString* escaped = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURLConnection* conn =[[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:escaped]] delegate:self];
    Connection = conn;
    NSLog(@"%s Connection=%@",__PRETTY_FUNCTION__,Connection);
}

In the same file I have this delegate-methods:

- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data {
    NSLog(@"%s connection=%@",__PRETTY_FUNCTION__,connection);
    [activeDownload appendData:data];
}

- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error {
    NSLog(@"%s connection=%@",__PRETTY_FUNCTION__,connection);
    activeDownload = nil;
    Connection = nil;
    //do nothing else; just ignore the error
}

- (void)connectionDidFinishLoading:(NSURLConnection*)connection {
    NSLog(@"%s Connection=%@",__PRETTY_FUNCTION__,Connection);
    NSString* answer = [[NSString alloc] initWithData:activeDownload encoding:NSUTF8StringEncoding];
    //do something usefull with the server's answer
    activeDownload = nil;
    Connection = nil;
}

When i run this app on a real device (not on the simulator), I get this messages in the console:

2012-11-22 20:41:51.309 BookMan[376:907] -[AppStatus sendStatus:] Connection=<NSURLConnection: 0x1dd7ff40>
2012-11-22 20:41:51.929 BookMan[376:907] -[AppStatus connection:didReceiveData:] Connection=<NSURLConnection: 0x1dd7ff40>
2012-11-22 20:41:51.935 BookMan[376:907] -[AppStatus connectionDidFinishLoading:] Connection=<NSURLConnection: 0x1dd7ff40>
purgeIdleCellConnections: found one to purge conn = 0x1dd8ff60

The purgeIdleCellConnections-message apears about 4 or 5 seconds after the connectionDidFinishLoading-message.

As you can see, the object-number of the purgeIdleCellConnections-message is not the same as the number of the connection I did create and use in my app.

Maybe IMPORTANT: I do get this message only when I run the App on a real device (iPhone 4 with iOS 6.0.1). This device uses a 3G-connection, not a WIFI-connection. At the moment I have no WIFI-network to test if this happens on a WIFI-connection too.
I do not get this message when I run the App on the simulator.

When I change the method sendStatus: to this:

- (void)sendStatus:(NSString*)url {
    NSString* escaped = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    //NSURLConnection* conn =[[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:escaped]] delegate:self];
    //Connection = conn;
    NSLog(@"%s Connection=%@",__PRETTY_FUNCTION__,Connection);
}

I get this output in the console:

2012-11-22 20:45:11.927 BookMan[391:907] -[AppStatus sendStatus:] Connection=(null)

I do not get the purgeIdleCellConnections-message when I do not create a connection.


So what does this message mean and why do I get it?:

purgeIdleCellConnections: found one to purge conn = (some object-ID)
like image 597
Hubert Schölnast Avatar asked Nov 22 '12 20:11

Hubert Schölnast


2 Answers

It means that, a connection which has been idle for too long has got its TCP connection closed. This is a basic mechanism, and it's log shouldn't bother you as Apple states on Technical QA1774, it's a debug message that has been, erroneously, left enabled.

This log is, indeed, only shown when WWAN connections are purged.

like image 128
Thecafremo Avatar answered Sep 30 '22 17:09

Thecafremo


Yes this the OS closing active connections over cellular data i.e 3G only. You shouldn't see this using a Wifi connection. It would seem that the OS purging the connections adds a bit of time to send data request to a server.

like image 36
Alex McPherson Avatar answered Sep 30 '22 16:09

Alex McPherson