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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:03:27+00:00 2026-06-08T07:03:27+00:00

I have an app that uses JSoup to connect to a web server, and

  • 0

I have an app that uses JSoup to connect to a web server, and it works fine. Unfortunately, the said web server isn’t very reliable. I get SocketException because of time-out connection quite often. I make the connection in a modified IntentService, and I just simply repeat onHandleIntent(intent) in the catch(Exception e) block.

catch(Exception e){
Log.d(Tag, "in catch Exception block...");   
onHandleIntent(intent);
}

Theoretically, this should work. But sometimes, I get stack over flow error, and the app ended quite ungracefully. So, what can I do to make it better?

I want to continue to call onHandleIntent, so, maybe I have to call it in iteration instead of recursively. If you can give me advice on how to implement this iteratively, it would be very helpful. Thanks!

  • 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-08T07:03:28+00:00Added an answer on June 8, 2026 at 7:03 am

    I want to continue to call onHandleIntent, so, maybe I have to call it in iteration instead of recursively.

    That is correct. If you handle this recursively, a server that continually times out will inevitably result in a stack overflow.

    If you can give me advice on how to implement this iteratively, it would be very helpful. Thanks!

    Something like this:

    for (int tries = 1; ; tries++) {
        Connection conn = null;
        try {
            // attempt to connect
            // do stuff
        } catch (SocketException ex) {
            if (/* timed out */ && tries < MAX_TRIES) {
                continue;
            }
            // report exception
        } finally {
            if (conn != null) {
                // close it
            }
        }
        break;
    }
    

    (Maybe someone can think of a less “clunky” way to write this …)

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

Sidebar

Related Questions

I have an app that uses LINQ to SQL to connect to database. I
I have an app that communicates with a server that uses HTTP Digest authentication.
I have a web app that uses google app engine .In ubuntu ,I start
I have java app that uses Axis to get data from web service. web
I have app that uses ClickOnce deployment. It works on about a dozen machines
I have an app that uses the OdbcConnection classes to connect to Oracle and
So, I have an app that uses a SQL Server express db. I have
I currently have a web app that uses the google maps API, PHP, and
I have an app that uses the ActionBar with tabs in combination with Fragments.
I have an app that uses webView. In the home screen of a website

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.