Thursday, 15 May 2014

Connection Refused in WearableListenerService / Android Wear when phone in sleep mode -


I'm developing an Android Work Watchface which sends the message API request by wearing on my mobile app, where the Internet reaches I am requesting to wear a wearable listener service, and on my mobile app, I get a message from wearing a message reakweed, and on an on message reissue, I start an AsyncTask to recover an image from the Internet.

All of this well normally .

However, if the phone is inactive for a few minutes (screen black, not connected to my Mac via USB), then I get an "Enonuerfuge - Rejected by Connection Server", when Async Task tries to get an inputstream on this line:

  InputStream = (InputStream) New URL (MULL) .getContent ();  

The exception is here:

  java.net.ConnectException: failed to connect to dl.dropboxusercontent.com/xx.xx.xxx.xx (port 443): connect failed: ECONNREFUSED (connection refused) libcore.io.IoBridge.connect (IoBridge.java:118) on java.net.PlainSocketImpl.connect (PlainSocketImpl.java:192) on java.net.PlainSocketImpl.connect At (PlainSocketImpl.java:460) at java.net.Socket.connect (Socket.java:838) com.android.okhttp.internal.Platform.connectSocket (platform.java:131) at com.android.okhttp.Connection . Connect to com.android.okhttp.internal.http.HttpEngine.connect (connection.java:101). On Com.android.okhttp.internal.http.HttpEngine.sendSocketRequest (HttpEngine.java Month 55) com.android.okhttp.internal.http.HttpURLConnectionImpl.execute (HttpURLConnectionImpl.java:345) on com.android.okhttp.internal com.android.okhttp.internal.http.HttpEngine.sendRequest (HttpEngine.java:206) on .http.HttpURLConnectionImpl.getResponse (HttpURLConnectionImpl.java:296) java.net.URLConnection.getContentType (URLConnection.java:326) java. on com.android.okhttp.internal.http.HttpsURLConnectionImpl.getContent (com.android.okhttp.internal.http.HttpURLConnectionImpl.getHeaderField (HttpURLConnectionImpl.java:143) (on URLConnection.java:193) on net.URLConnection.getContent httpsURLConnectionImpl.java:169) on java.net.URL.getContent (URL.java:455) on wear.webcam.MobileRequestListenerService $ MyImageLoaderTask.doInBackground (MobileRequestListenerService Java: 479) wear.webcam.MobileRequestListenerService $ MyImageLoaderTask.doIn Background (MobileRequestListenerService.java:451) android.os.AsyncTask at $ 2.call (asyncTask.javamore88 on java.util.concurrent.FutureTask.run) (on FutureTask. Java: 237) java.util.concurrent.ThreadPoolExecutor $ on worker android.os.AsyncTask $ SerialExecutor $ 1.run (AsyncTask.java:231) java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1112) on . Java.lang.Thread.run (ThreadPoolExecutor.java tithi87) run by (Thread.java:841) Reason: Libcore.io.ErrnoException: Connect failed: (Connection refused) libcore.io at libcore.io.IoBridge.connectErrno .BlockGuardOs.connect (BlockGuardOs.java:85) on ECONNREFUSED libcore.io.Posix.connect (IoBridge.java.131) at libcore.io.IoBridge.connect (IoBridge.java116) ... 23 More  
  • My app retries one minute later, and when the phone is turned on (on screen), it works!
  • It has nothing to do with the server / URL, because I am getting the same error in different servers.
  • It has nothing to do with WiFi, because it does not care about WiFi or normal network.
  • It is in the PROD / signed and DEBUG version
  • I'm checking that the network is available just before the call, and I'm getting "true" back, Is in! Public boolean network available () {connectivity manager cm = (connectivity manager) getSystemService (reference CONNECTIVITY_SERVICE) ; NetworkInfo NetworkInfo = Sem.ActiveNetworkInfo (); // If there is no network available, NetworkInfo will be zero // Check otherwise if we are connected (NetworkInfo! = Null & NetworkInfoIne.Connect ()) {true; } return false; }

    It seems that this problem can be solved by getting a decent - though it has not solved the problem yet.

    Any help is appreciated !!!

    Android 4.4.4 Sony Xperia Z1; Android Wear 5.0.2. Solution: It has been found, because the energy saving options were Xperia: it's called "Stamna-Modes". Was set, so that the device was not kept awake.


No comments:

Post a Comment