Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8144055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:16:11+00:00 2026-06-06T13:16:11+00:00

I’m working on an iOS app that uses a NSMutableURLRequest and a NSURLConnection to

  • 0

I’m working on an iOS app that uses a NSMutableURLRequest and a NSURLConnection to send data to my server. I need to display the error message when it fails. My code for sending the request is shown below

const int TIMEOUT = 120;

-(void)send:(id<NSURLConnectionDelegate>)delegate
{
    bodyContents = [bodyContents stringByAppendingFormat:@"--%@--",boundry];
    NSData *data = [bodyContents dataUsingEncoding:NSUTF8StringEncoding];
    [request setHTTPBody:data];
    [request setValue:[NSString stringWithFormat:@"%i",[data length]+4] forHTTPHeaderField:@"Content-Length"];
    NSLog(@"Timeout before setting custom is %f",request.timeoutInterval);
    [request setTimeoutInterval:TIMEOUT];
    NSLog(@"Timeout after setting custom is %f",request.timeoutInterval);
    NSURLConnection *connection = [[NSURLConnection alloc]initWithRequest:request delegate:delegate];
    if(connection)
        NSLog(@"Connection good");
    else
        NSLog(@"Connection not so good");
}

//in the delegate class
-(void)connectionDidFinishLoading:(NSURLConnection*)connection
{
    NSLog(@"connectionDidFinishLoading");
}

-(void)connection:(NSURLConnection*)connection didFailWithError:(NSError *)error
{
    NSLog(@"Failed with error %@",error);
    btnCancel.title = @"Retry";
    self.navigationItem.hidesBackButton = NO;
    [self showAlertDialog:[NSString stringWithFormat:@"%@",[error localizedDescription]] :@"Error"];
}

I would expect the didFailWithError message to be called after 2 minutes of no response. Instead it’s called after about 15 seconds of no response which doesn’t make any sense. I looked at the documentation to check if I was setting the timeout incorrectly, the only thing I could find is that the minimum timeout for a post with a body is 240 seconds which I have come to begrudgingly accept.

The output from running the app looks like this:

2012-06-22 16:49:12.393 Media Upload[672:707] Timeout before setting custom is 240.000000

2012-06-22 16:49:12.394 Media Upload[672:707] Timeout after setting custom is 240.000000

2012-06-22 16:49:12.395 Media Upload[672:707] Connection good

2012-06-22 16:49:29.174 Media Upload[672:707] Failed with error Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." etc

I’m more than a little confused as to why it’s timing out so quickly. The server is not up when the connection is created so I’m not even sure why it says Connection good instead of connection not so good, but that’s a different problem (I hope) Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:16:12+00:00Added an answer on June 6, 2026 at 1:16 pm

    So, I suspect that the answer is all in the semantics.

    As for the “Connection good” logging instead of “Connection not so good”, this is because init’ing a connection does not wait for it to do anything on the network. It does cause it to start right away, but not before it returns from the init method.

    The more interesting (read:misleading) issue is with the timeout. I suspect that what the timeout setting really means is, “If I have established a connection, but the server just hasn’t given me response bytes yet”. Which is distinct from “I have been trying, but cannot connect”. It makes a certain amount of sense when you think of it this way; One timeout value just for all the ‘network’ stuff (routing and handshakes) and another for the actual payload to be processed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.