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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:27:35+00:00 2026-06-11T18:27:35+00:00

I am working on an application that uses HttpUrlConnection, connects beautifully with the server,

  • 0

I am working on an application that uses HttpUrlConnection, connects beautifully with the server, but when fetching data from it says connection time out IOException.

The internet, & network permissions are already set in the android.manifest; there are no bars showing up in the android emulator (does this says anything).

Read at developer.android.com:
The functional limitations of the emulator include:
– No support for determining network connected state
– and few others….

Any help will be highly appreciated. And I don’t have an actual device to test this.

Received server info do gets printed in the logcat.

Thanks…

Here is the code:

URL url = new URL(urlString);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
try {
    Log.i(INFO_TAG, "Received server:" + conn.toString());
    conn.setInstanceFollowRedirects(true);
    conn.setRequestMethod("GET");
    conn.setRequestProperty("Content-length", "0");
    conn.setUseCaches(false);
    conn.setAllowUserInteraction(false);
    conn.setConnectTimeout(25000 /* milliseconds */);
    conn.setReadTimeout(15000/* 10000 *//* milliseconds */);
    // conn.setDoInput(true);
    // Starts the query
    conn.connect();
    status = conn.getResponseCode();
    Log.d(DEBUG_TAG, "Status recevied is: " + conn.getResponseCode());
    responseCode = status;
    if (responseCode == 200) {
        Log.i(INFO_TAG, "URL Connection OK");
        contentIs = conn.getInputStream();
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(contentIs));
        String line;
        while ((line = reader.readLine()) != null) {
            builder.append(line);
            Log.i(INFO_TAG, "Data Read is: " + line);
        }
    } else {
        Log.d(DEBUG_TAG, "Could not read data from web server");
        Log.e(ConnectAndGetData.class.toString(),
            "Failed to download content");
    }
}// end of try
catch (Exception ex) {
    // This is currently being printout
    Log.d(DEBUG_TAG, "Received an exception" + ex.toString(), ex);
    ex.printStackTrace();
    throw new IOException("Error Connecting" + ex.toString());// "Error connecting");
} finally {
    if (contentIs != null) {
        contentIs.close();
        conn.disconnect();
    }
}

One more thing since, it throws a connection timeout exception it does not debug info at this line is printed:
Log.d(DEBUG_TAG, “Status recevied is: ” + conn.getResponseCode());

  • 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-11T18:27:36+00:00Added an answer on June 11, 2026 at 6:27 pm

    The problem was not the code above, it was the server code (the main culprit). Now implemented a web service and the code above is working fine.

    Thanks all for commenting…

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

Sidebar

Related Questions

I've been working on an application that uses xVal's server side validation with data
I'm working on an application that uses multiple threads to process its data. The
I'm working on an application that uses a list to handle previous guesses from
I am working on an application that uses the Game Center feature from iOS
I am working on building an iPhone application that uses an external server to
I'm developing a ruby application that uses the models and data from another Ruby
i am working on an application that uses FastMM4 , from sourceforge.net . So
I am working on an application that uses Oracle's built in authentication mechanisms to
I am currently working on an application that uses a TableViewer in several places
I am working on a php that application that uses ajax. On all the

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.