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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:22:16+00:00 2026-05-12T09:22:16+00:00

I have a J2ME app running on my mobile phone(client), I would like to

  • 0

I have a J2ME app running on my mobile phone(client),

I would like to open an HTTP connection with the server and keep polling for updated information on the server.

Every poll performed will use up GPRS bytes and would turn out expensive in the long run, as GPRS billing is based on packets sent and received.
Is there a byte efficient way of polling using the HTTP protocol?.

I have also heard of long polling, But I am not sure how it works and how efficient it would be.

Actually the preffered way would be for the Server to tell the phone app that new data is ready to be used that way polling won’t be needed to be done, however I don’t know of these techniques especially in J2ME.

  • 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-12T09:22:16+00:00Added an answer on May 12, 2026 at 9:22 am

    If you want solve this problem using HTTP only, long polling would be the best way. It’s fairly easy. First you need to setup an URL on server side for notification (e.g. http://example.com/notify), and define a notification protocol. The protocol can be as simply as some text lines and each line is an event. For example,

      MSG user1
      PHOTO user2 album1
      EMAIL user1
      HEARTBEAT 300
    

    The polling thread on the phone works like this,

    1. Make a HTTP connection to notification URL. In J2ME, you can use GCF HttpConnection.
    2. The server will block if no events to push.
    3. If the server responds, get each line and spawn a new thread to notify the application and loopback to #1.
    4. If the connection closes for any reason, sleep for a while and go back to step 1.

    You have to pay attention to following implementation details,

    1. Tune HTTP timeouts on both client and server. The longer the timeout, the more efficient. Timed out connection will cause a reconnect.
    2. Enable HTTP keepalive on both the phone and the server. TCP’s 3-way handshake is expensive in GPRS term so try to avoid it.
    3. Detect stale connections. In mobile environments, it’s very easy to get stale HTTP connections (connection is gone but polling thread is still waiting). You can use heartbeats to recover. Say heartbeat rate is 5 minutes. Server should send a notification in every 5 minutes. If no data to push, just send HEARTBEAT. On the phone, the polling thread should try to close and reopen the polling connection if nothing received for 5 minutes.
    4. Handling connectivity errors carefully. Long polling doesn’t work well when there are connectivity issues. If not handled properly, it can be the deal-breaker. For example, you can waste lots of packets on Step 4 if the sleep is not long enough. If possible, check GPRS availability on the phone and put the polling thread on hold when GPRS is not available to save battery.
    5. Server cost can be very high if not implemented properly. For example, if you use Java servlet, every running application will have at least one corresponding polling connection and its thread. Depending on the number of users, this can kill a Tomcat quickly 🙂 You need to use resource efficient technologies, like Apache Mina.

    I was told there are other more efficient ways to push notifications to the phone, like using SMS and some IP-level tricks. But you either have to do some low level non-portable programming or run into risks of patent violations. Long polling is probably the best you can get with a HTTP only solution.

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

Sidebar

Related Questions

I have a j2me midlet running on a cell phone. The code works fine,
I have a problem with an J2ME client app, that sends data to an
I have made an app for j2me Mobile, now I wanted to give it
In my j2me App I have tried canvas which works great on Nokia phone
How do I autodial a mobile using a j2me app running on it based
Using J2ME, netbeans 7.2, Developing a mobile app.. I have converted the Datefield value
I have read in many places that network connection in a j2me app should
I would like to create FM tuner for all major mobile platforms(Black berry,Android,Iphone,J2ME).Are they
I have j2me application in which video is played. On the client device it
Does every j2me enabled mobile have GPS service so that the developer can locate

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.