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

  • Home
  • SEARCH
  • 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 7030195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:38:16+00:00 2026-05-28T00:38:16+00:00

Sorry, this is along one to document.. OLD SETUP I have a J2ME client

  • 0

Sorry, this is along one to document..

OLD SETUP

I have a J2ME client app which connects to a server at 3 second intervals. The connections are handled in a separate thread. The thread runs in a while loop and does as follows:

  1. Open HTTP Connection
  2. Receive Response & send to Main UI Thread for processing
  3. Sleep for 3 seconds
    Repeat

Server is Apache and KeepAlive is off. HTTP Requests from the client have a Timeout of 10 seconds. Each loop takes about 4.5 seconds (1.5 seconds total latency).

Every so often (once every 1 or 2 hours), under low coverage (poor 3G/GPRS signal) the thread receives an IO block and hangs at step 1 above. I think what is happening is the connection somewhere along the line has died, but the app does not know it and is waiting for a response. The network (O2 in this case) is to blame I think. The connection stays alive for maybe 30 minutes and eventually dies and returns -1 response length to the app and the thread eventually continues. To combat this relatively rare issue I simply abandoned the thread if the response took longer than 60 seconds, and created a new one.

Up until recently this was not a major issue, however we changed our network setup as follows:


NEW SETUP

  1. Due to lower bandwidth restrictions we slowed down the interval to 5
    seconds.
  2. We now route all connections through an SSL Tunnel to our server.
  3. HTTP requests from the client still have a timeout of 10 seconds on App*

The loop was taking about 7.5 seconds (2.5 seconds total latency) to complete with these changes. The reason the latency increased was the handshake over SSL was required for each single connection (due to KeepAlive off). We were advised to switch KeepAlive ON on the apache server which would mean one handshake and then a persistent http connection for subsequent requests. We did this, and for the most part it has considerably improved the connection speed. The loop is down to 6.5 seconds.

So we can now add this to our config changes for the new setup:

  1. HTTP KeepAlive was switched to ON on the server (to enable to the persistent TCP connection)

However, in poor 3G/GPRS areas, the thread blocking issue is much more frequent and has become a major issue – it happens as much as 50% of the time in really poor coverage areas. I have received a Java out of memory exception a few times telling me the app could not fork a new thread.. In addition, in good 3G areas we also see this thread blocking issue now which had not happened before.

I have clearly done something wrong in this setup, as persistent http connections and the underlying TCP is quite reliable

*We managed all these changes without an app re-write, but the http timeout of 10 seconds will require an app re-write. Perhaps this timeout is causing the issue?

Thanks in advance for any assistance in this.

  • 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-28T00:38:17+00:00Added an answer on May 28, 2026 at 12:38 am

    In case someone has a similar issue, KeepAliveTimeout was key here. It was set at 5 seconds rendering KeepAlive useless.

    I’ve increased it to 30 seconds which effectively creates a persistent connection and the app is flying along now.

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

Sidebar

Related Questions

I have this LINQ query (sorry it;s a long one) that query sets from
this post is a long one sorry for that but the problem is complex
Sorry this is not a very well defined question, I am thinking about an
Ok sorry this might seem like a dumb question but I cannot figure this
Sorry for this not being a real question, but Sometime back i remember seeing
Sorry if this sounds like a really stupid question, but I need to make
Sorry if this is a little off-topic for regular stackoverflow questions, but we're tearing
Sorry if this is a comp-sci 101 question. I'm just unsure if I'm missing
Sorry if this question seems trivial to many here. In a C++ code there
Sorry if this is a dup; I haven't found any questions that pose quite

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.