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 7430973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:13:24+00:00 2026-05-29T09:13:24+00:00

I am using the great RestKit Framework for an iPhone Application. I have got

  • 0

I am using the great RestKit Framework for an iPhone Application.
I have got a method, where I send requests to a webservice. Sometimes four or more requests per 30 seconds.

My sendMethod looks like:

 - (void) sendLocation {

NSString *username = [userDefaults objectForKey:kUsernameKey];    
NSString *password = [userDefaults objectForKey:kPasswordKey];
NSString *instance = [userDefaults objectForKey:kInstanceKey];
NSString *locationname = self.location.locationname;

NSString *url = [[NSString alloc] initWithFormat:@"http://www.someadress.com/%@", instance];

RKClient *client = [RKClient clientWithBaseURL:url username:username password:password];

// Building my JsonObject
NSDictionary *locationDictionary = [NSDictionary dictionaryWithObjectsAndKeys: username, @"username", locationname, @"locationname", nil];
NSDictionary *jsonDictionary = [NSDictionary dictionaryWithObjectsAndKeys:locationDictionary, @"location", nil];

NSString *JSON = [jsonDictionary JSONRepresentation];
RKParams *params = [RKRequestSerialization serializationWithData:[JSON dataUsingEncoding:NSUTF8StringEncoding]MIMEType:RKMIMETypeJSON]; 

[client  post:@"/locations" params:params delegate:self];
 }

Sometimes (especially when sending more requests after another) the value of the count property of the RKRequestQueue Object is > 1.
When my application enters background and then enters foreground the requests in the queue (when foreground is entered) are sent to my Webservice and the delegate

- (void)request:(RKRequest*)request didLoadResponse:(RKResponse*)response {)

for all requests will be called.

So the question is:
Why doesnt RestKit send some requests immediately (my Webservice doesnt receive anything while a request is stored in the queue)???

Does anyone know a solution or had/has the same problem?

  • 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-05-29T09:13:25+00:00Added an answer on May 29, 2026 at 9:13 am

    I noticed this line where you create the RKClient:

    RKClient *client = [RKClient clientWithBaseURL:url username:username password:password];
    

    This basically creates new instance each time sendLocation method is called – are you sure this is your desired behavior? If the url, username and password does not change, you can access previously created client by calling [RKClient sharedClient]. In your current approach, new request queue is created for each new client.

    Now back to the point. Take a look on this property of the RKRequestQueue:

    /**
    * The number of concurrent requests supported by this queue
    * Defaults to 5
    */
    @property (nonatomic) NSUInteger concurrentRequestsLimit;
    

    As you can see this defaults to 5, so if you have more than that in any of your queues they will wait until the ongoing requests are processed. You also mentioned that the requests stack up when the application is moved to background, and then when it enters the foreground all of them are dispatched. You can control how your requests behave like this:

    - (void)backgroundUpload {
        RKRequest* request = [[RKClient sharedClient] post:@"somewhere" delegate:self];
        request.backgroundPolicy = RKRequestBackgroundPolicyNone; // Take no action with regard to backgrounding
        request.backgroundPolicy = RKRequestBackgroundPolicyCancel; // If the app switches to the background, cancel the request
        request.backgroundPolicy = RKRequestBackgroundPolicyContinue; // Continue the request in the background
        request.backgroundPolicy = RKRequestBackgroundPolicyRequeue; // Cancel the request and place it back on the queue for next activation
    }
    

    I have found this solution here. Scroll down to Background Upload/Download section.

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

Sidebar

Related Questions

iam using AVFoundation Framework to play mp3 file ,everything works great ، i have
I have started using Star UML application and its great. Is there a way
I have been using NSURLConnection's sendAsynchronousRequest:queue:completionHandler: method which is great. But, I now need
I'm using XSLT and having great success, just got a couple of problems. Warning:
I have been using this code with great success to pull out the first
I'm using Lawrence Philips Double-Metaphone algorithm with great success, but I have found the
We are using Hudson for our Continuous Integration server and it's great. We have
I have been using ClojureBox with great success to learn both Clojure and emacs.
I have a ASP.net MVC2 website that was working great when using Visual Studio
I am working in a graph using the great framework core-plot (in desktop OSX).

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.