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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:20:47+00:00 2026-05-25T00:20:47+00:00

I have a WebView that is fed from a background thread via a ServerSocket

  • 0

I have a WebView that is fed from a background thread via a ServerSocket on localhost. This works very well, but sometimes the background thread randomly stops accepting requests (“Web page not available”). After some time, it works again without any changes, that is, without restarting the thread or the socket or calling accept() again.

EDIT 2: Further investigation showed that WebView seems to have a (separate?) timeout value for localhost connections that is so small that sometimes the server thread doesn’t get a chance to handle the request. As a workaround, I can reload the page when WebClient.onReceivedError is invoked, which eventually loads the page. Anyone having the same problem?

When I open the debugger, I can see that the server thread is still running properly and is waiting (blocked) in the ServerSocket.accept() method (or, more precisely, in OSNetworkSystem.accept(...)). However, accept() doesn’t seem to receive the incoming request.

There is is nothing special in my code:

ServerSocket serverSocket = new ServerSocket(port);
serverSocket.setSoTimeout(0);

while (!shutdown) {
    Socket socket = null;
    try {
        socket = serverSocket.accept();
        // Parse request and create response
    } catch (Exception e) {
        // ...
    } finally {
        // ... close socket
    }
}

I use the same code on Windows/Mac and have never experienced any such problems.

This seems to me like a bug in Android, perhaps related to power management optimizations. Any clues?

EDIT: The problem does not occur on Android 2.x, only on Android 3.1 (Samsung Galaxy Tab 10.1).

  • 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-25T00:20:47+00:00Added an answer on May 25, 2026 at 12:20 am

    This problem is a bug in Android.

    I have filed a bug report under http://code.google.com/p/android/issues/detail?id=19427

    EDIT: As a workaround, I added some code to reload the page whenever a connection error occurs. This has worked quite well so far.

    webView.setWebViewClient(new WebViewClient(){
        String prevFailingUrl;
        int retryCount;
        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            if (errorCode == WebViewClient.ERROR_CONNECT) {
                if (failingUrl.equals(prevFailingUrl)) {
                    retryCount++;
                } else {
                    retryCount = 1;
                }
                if (retryCount <= 3) {
                    webView.reload();
                }
            }
            prevFailingUrl = failingUrl;
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WebView that is formatted via a CSS file - I dynamically
This is an obscure, possibly hardware dependent error. I have a webview that is
I have a webview that's playing a video, and I want it to appear
I currently have a webview that when you press a mp3 link, the mp3
I have javascript in a webview that only loads sometimes. Other times it doesn't,
i have a string called htmlString that contains some informations formatted in html. I
I have an app that create a shortcut in the following way: Intent shortcutIntent
Hi I am trying to load a webview that uses javascript and html5. However,
HI am making a application in which the the user enter data into text

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.