Pregunta

I am sending out a NSURLConnection with an async request so that I can get back a cookie and then do something with that cookie. On NewRelic the server is saying that it is processing the request under 1 second. But when I do time stamping on the iOS side I see it take 5-10 seconds to get to the completionHandler... has anyone run into this? I have reduced all other network bandwidth uses to nothing and I still have this issue. Other requests to other endpoints seems quite fast.

So the NewRelic report seems to report the request in that time stamp span to be only 400ms... but like I said Im seeing it at 5000ms to 10000ms.

Thoughts? Here is my code.

[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
    if(response)
    {
        // code to handle with the response
        NSLog(@"timestamp after -success: %@",[NSDate date]);

        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response;
        if ([httpResponse respondsToSelector:@selector(allHeaderFields)]) {
            NSDictionary *fields = [(NSHTTPURLResponse *)response allHeaderFields];

           // NSString *cookie = [fields valueForKey:@"Set-Cookie"]; // It is your cookie

            NSArray * all = [NSHTTPCookie cookiesWithResponseHeaderFields:[httpResponse allHeaderFields] forURL:[NSURL URLWithString:[theUrlString stringByAddingPercentEscapesUsingEncoding:                                                                                                                            NSUTF8StringEncoding]]];

            DLog(@"%d", all.count);

            for (NSHTTPCookie *cookie in all) {
                DLog(@"Name: %@ : Value: %@", cookie.name, cookie.value);
            }
            [[WDDataController sharedInstance] resumeOperations];
            [[NSNotificationCenter defaultCenter] postNotificationName:SERVICE_AUTHENTICATED object:nil];

        }
    }
    if (error){
        NSLog(@"timestamp after error: %@",[NSDate date]);
         // code to handle with the error
         NSLog(@"Error: &@",error);
         [[WDDataController sharedInstance] resumeOperations];
    }

}];
¿Fue útil?

Solución

What I can say for now is the request time span reported by New Relic is the HTTP request round trip time, and does not include any work done in completion handlers. Do you think that New Relic is causing this delay or should be reporting for a longer duration?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top