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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:25:02+00:00 2026-06-03T17:25:02+00:00

I have this static function which basicly makes a connection to a webpage, send

  • 0

I have this static function which basicly makes a connection to a webpage, send post data along with it and return the received response (JSON object)

The problem that I am having is that no matter what timeout i set, it very often gives a timeout when it is only trying 1 second, with the timeout being 6 seconds that should not happen.

public static String makeRequest(String path, String info) throws Exception 
{
  HttpParams httpParameters = new BasicHttpParams();
  int timeoutConnection = 6000;
  HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
  int timeoutSocket = 6000;
  HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);

  DefaultHttpClient httpclient = new DefaultHttpClient(httpParameters);
  HttpPost httpost = new HttpPost(path);
  StringEntity jsonobj = new StringEntity(info);
  httpost.setEntity(jsonobj);
  httpost.setHeader("Accept", "application/json");
  httpost.setHeader("Content-type", "application/json");
  ResponseHandler responseHandler = new BasicResponseHandler();

  String response = httpclient.execute(httpost, responseHandler);
  return response;

Now I have seen some issues like this but I could not find an answer that could help me.
Some say it is due to the fact that it is not threadsafe, however, I do not do multiple calls at the same time, it is all done in order. The issue evens occurs on the first try, which should not happen because of this reason as there are no multiple connection/httpposts yet, let alone from different threads.

However it does happen a lot lately, sometimes it did not occur for a few days or barely in those days.

I tried looking at the AndroidHttpClient, but it does not seem to support HttpPost, so that is not usefull either (or I am wrong with this?)

The data for both path and info is correct, tested it. Also my server does not have issues.

Some say it can be your network, but I have it on 3 wifi networks tested today. Strangly, on the internet connection of my mobile provider it does not or barely occur.

I have read in one answer that it may be because of the ISP changing header information. I have tried using different values for the user-agent but that also did not work.

I hope someone can be of help and for that i would be grateful as it really frustrates me that this keeps happening.

  • 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-03T17:25:03+00:00Added an answer on June 3, 2026 at 5:25 pm

    If TCP detects a connection reject (i.e. an incoming RST) before the timeout period, it is a failure. There is no point in waiting out the timeout in this case, and it is to be expected that a retry will only fail again the same way. The timeout is for the case when there is no response.

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

Sidebar

Related Questions

Say I have this repeater which makes use of a public function called Test
I have this function public static implicit operator MyClass(string v) { return new MyClass(v);
I have this function: public static string Join(this IEnumerable<string> strings, string separator) { return
I have implemented this function: static <X,Y> Y castOrNull(X obj) { try { return
Let's have this class class A { protected static function ident() { return I
Suppose I have two functions which look like this: public static void myFunction1(int a,
I have this static callback function in MyClass, and I try to call another
I have this function: static void Func1<T>(T x, T y) { dynamic result =
I have this user defined function. public partial class UserDefinedFunctions { static int i;
I have a function defined like this: public static void ShowAbout(Point location, bool stripSystemAssemblies

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.