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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:48:55+00:00 2026-05-23T17:48:55+00:00

I am trying to implement a long polling push-service on my android application (based

  • 0

I am trying to implement a long polling push-service on my android application (based on Microsofts AUTD ActiveSync -> http://technet.microsoft.com/en-us/library/aa997252.aspx).

I have already realised the server part with Servlets 3.0 running on Tomcat 7.0. I have tested my AsyncServlets with CURL, everything works fine.

That’s how I tested my AsyncServlet:

curl "https://webservice.mydomain.net/push?id=1&heartbeat=180000" --insecure --user user:password -D -

Server response after 3 minutes (Heartbeat Interval)

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 01:00:00 CET
Content-Type: application/json;charset=ISO-8859-1
Content-Length: 0
Date: Sat, 15 Jan 2011 23:38:57 GMT

On my android application I used following code:

HttpParams httpParams = mDefaultHttpClient.getParams();
HttpConnectionParams.setConnectionTimeout(httpParams, CONNECTION_TIMEOUT);
HttpConnectionParams.setSoTimeout(httpParams, mHeartbeat + TIMEOUT_TOLERANCE);
mDefaultHttpClient.setParams(httpParams);

HttpGet httpGet = new HttpGet(mPushURL);
httpGet.addHeader("Accept", "application/json");

try {
    Log.i(TAG, "Executing GET(PUSH) request " + httpGet.getRequestLine());
    HttpResponse httpResponse = mDefaultHttpClient.execute(httpGet);
    Log.i(TAG, httpResponse.getStatusLine().toString());
    Log.i(TAG, convertInputStream(httpResponse.getEntity().getContent())); //For testing purposes
} catch (ClientProtocolException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}

I ran several tests. If I use a 70 seconds heartbeat interval I receive the response. If I use a > 70 seconds heartbeat interval I receive (after the specified heartbeat interval) a SocketTimeoutException instead of my HTTP 200 OK Response. (To clarify: My set SocketTimeout(SoTimeout) is working correctly, but maybe the connection get lost, I have no idea why).

Thanks for every response.

  • 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-23T17:48:56+00:00Added an answer on May 23, 2026 at 5:48 pm

    Use URLConnection and set readTimeOut. Buy it is hard to say. i think android network layer is freezing open connections. (i am working on similar project. Could’t find why open connections are freezing)

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

Sidebar

Related Questions

I'm trying to implement a comet style, long polling connection using an XMLHttpResponse object.
We are trying to implement a REST API for an application we have now.
I am trying to implement a Comet style (e.g. chat) application using IronPython. While
I'm trying to implement long division for bignums. I can't use a library like
I'm trying to implement Future.get(long, TimeUnit) in terms of TimeUnit.timedWait(Object, long) . It's not
Here's a long one. I'm trying to implement horizontal scrolling in my site. It's
I am currently trying to implement this into my current code: http://cubiq.org/iscroll I have
I'm trying to implement my own Hibernate NamingStrategy based on the ImprovedNamingStrategy. This is
I'm trying to write test harness for part of my Android mapping application. I
I've been trying to implement this for a long time and I have gotten

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.