0

I am running a NativeScript-Vue application (TNS Android v5.1.0) on Mojave v10.14.3 with Android Studio v3.3.1 and Android emulator v28.0.23.

The Android emulator I am using (Nexus 6, API 25, Android 7.1.1 (Google APIs), x86) loses ability to make HTTP requests. The request hangs for a couple of minutes and eventually times out. I am using axios as the HTTP client to consume a remote C#.NET API (this is a client's API so I do not have access to it directly).

I found this SO post and tried most of the solutions. Some of them seemed to work, but then after a few minutes, the problem reoccurs.


Solutions I have tried:

  • Wiped data from emulator via AVD manager
  • Cold booted emulator via AVD manager
  • Created a new emulator via AVD manager
  • Set emulator proxy status to "No proxy" instead of using Android Studio's default proxy settings
  • Ran adb kill-server
  • Added 8.8.8.8 and 8.8.4.4 as DNS servers for my Mac
  • Started emulator with a specified DNS server, e.g. $ANDROID_HOME/emulator/emulator -avd Nexus_6_API_25 -dns-server 8.8.8.8,8.8.4.4
  • Attempted on Genymotion emulator (same issue)
  • Set WiFi as first in the Network Service order
  • Rebooting system; works for a few minutes then issue reoccurs

Additional information:

  • I am using WiFi and have not recently switched from LAN.
  • Chrome doesn't have internet access either.
  • The application works as expected on the iOS simulator and on physical android devices.
  • I installed Mojave recently, however the issue existed previously, although not as frequently it seemed.
  • JDK-8 and Android-SDK were installed via Homebrew following the NativeScript docs here.

I am fairly new to mobile development, please let me know if any more information is needed.

Does anyone know how I can fix this issue? I have limited access to a physical device so getting this fixed would be a tremendous help. Thanks!


HTTP Request example:

// api/config.js
import axios from "axios";

export default axios.create({
    baseURL: "https://testapi.org",

    headers: {
        "Content-Type": "application/json",
    }
});

// store/modules/auth.js
import api from "api/config.js";

const actions = {
    login: async function(context, payload) {
        try {
            const response = await api.post("/api/account/login", payload);
            context.dispatch("setUser", response.data.user);
        } catch (error) {
            console.log(error);
        }
    }
};

export default {
    namespace: true,
    actions
};

Logcat output:

02-28 14:12:40.742  1722  1816 D ConnectivityService: NetworkAgentInfo [MOBILE (LTE) - 100] validation failed
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter: Error sending ping
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter: java.net.SocketTimeoutException: SSL handshake timed out
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at com.google.android.gms.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at com.google.android.gms.org.conscrypt.NativeSsl.doHandshake(:com.google.android.gms@13280022@13.2.80 (040700-211705629):8)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(:com.google.android.gms@13280022@13.2.80 (040700-211705629):15)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at com.android.okhttp.Connection.connectTls(Connection.java:235)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at com.android.okhttp.Connection.connectSocket(Connection.java:199)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at com.android.okhttp.Connection.connect(Connection.java:172)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:130)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:329)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:405)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:521)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at bsc.a(SourceFile:230)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at bsf.run(SourceFile:174)
02-28 14:12:48.271  2939  3095 E GoogleConversionReporter:  at java.lang.Thread.run(Thread.java:761)
02-28 14:12:49.375  2651  2932 W Conscrypt: Could not set socket write timeout: java.lang.reflect.InvocationTargetException
02-28 14:12:49.376  2651  2932 W Conscrypt:     at java.lang.reflect.Method.invoke(Native Method)
02-28 14:12:49.376  2651  2932 W Conscrypt:     at com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@13280022@13.2.80 (040700-211705629):13)
02-28 14:12:49.376  2651  2932 W Conscrypt: Caused by: android.system.ErrnoException: setsockopt failed: EBADF (Bad file descriptor)
02-28 14:12:49.376  2651  2932 W Conscrypt:     at libcore.io.Posix.setsockoptTimeval(Native Method)
02-28 14:12:49.376  2651  2932 W Conscrypt:     at libcore.io.ForwardingOs.setsockoptTimeval(ForwardingOs.java:157)
02-28 14:12:50.171  2651  2930 W Conscrypt: Could not set socket write timeout: java.lang.reflect.InvocationTargetException
02-28 14:12:50.171  2651  2930 W Conscrypt:     at java.lang.reflect.Method.invoke(Native Method)
02-28 14:12:50.171  2651  2930 W Conscrypt:     at com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@13280022@13.2.80 (040700-211705629):13)
02-28 14:12:50.172  2651  2930 W Conscrypt: Caused by: android.system.ErrnoException: setsockopt failed: EBADF (Bad file descriptor)
02-28 14:12:50.172  2651  2930 W Conscrypt:     at libcore.io.Posix.setsockoptTimeval(Native Method)
02-28 14:12:50.172  2651  2930 W Conscrypt:     at libcore.io.ForwardingOs.setsockoptTimeval(ForwardingOs.java:157)
02-28 14:12:50.283  2651  2929 W Conscrypt: Could not set socket write timeout: java.lang.reflect.InvocationTargetException
02-28 14:12:50.284  2651  2929 W Conscrypt:     at java.lang.reflect.Method.invoke(Native Method)
02-28 14:12:50.284  2651  2929 W Conscrypt:     at com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@13280022@13.2.80 (040700-211705629):13)
02-28 14:12:50.284  2651  2929 W Conscrypt: Caused by: android.system.ErrnoException: setsockopt failed: EBADF (Bad file descriptor)
02-28 14:12:50.284  2651  2929 W Conscrypt:     at libcore.io.Posix.setsockoptTimeval(Native Method)
02-28 14:12:50.284  2651  2929 W Conscrypt:     at libcore.io.ForwardingOs.setsockoptTimeval(ForwardingOs.java:157)
02-28 14:12:51.482  2651  3200 W Conscrypt: Could not set socket write timeout: java.lang.reflect.InvocationTargetException
02-28 14:12:51.482  2651  3200 W Conscrypt:     at java.lang.reflect.Method.invoke(Native Method)
02-28 14:12:51.482  2651  3200 W Conscrypt:     at com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@13280022@13.2.80 (040700-211705629):13)
02-28 14:12:51.482  2651  3200 W Conscrypt: Caused by: android.system.ErrnoException: setsockopt failed: EBADF (Bad file descriptor)
02-28 14:12:51.482  2651  3200 W Conscrypt:     at libcore.io.Posix.setsockoptTimeval(Native Method)
02-28 14:12:51.482  2651  3200 W Conscrypt:     at libcore.io.ForwardingOs.setsockoptTimeval(ForwardingOs.java:157)
02-28 14:13:05.945  5154  5156 I art     : Do partial code cache collection, code=30KB, data=30KB
02-28 14:13:05.946  5154  5156 I art     : After code cache collection, code=30KB, data=30KB
02-28 14:13:05.946  5154  5156 I art     : Increasing code cache capacity to 128KB
02-28 14:13:14.458  2363  5301 E WakeLock: GCM_HB_ALARM release without a matched acquire!
Dominic Serrano
  • 124
  • 1
  • 5
  • Can you show us some code of your Http Request? Is your endpoint Http or Https? – Manoj Feb 28 '19 at 22:35
  • Sure, I can add an example of my HTTP requests. I don't think that is the issue however, since the application does run on iOS and physical Android devices. The endpoint is https. – Dominic Serrano Feb 28 '19 at 23:05
  • I faced the same issue and when I added 8.8.8.8 and 8.8.4.4 as DNS servers , it solved the issue – Narendra Mar 01 '19 at 03:49
  • @NarendraMongiya unfortunately I tried that, but the fix did not persist. It was fine for a few minutes, then the emulator lost network access again. – Dominic Serrano Mar 01 '19 at 15:49
  • You said, "Chrome doesn't have internet access either.". This the chrome in the Android, right? I'd say there is nothing wrong with your code (you even said it works for a while). Something else must be blocking the network, like a firewall or traffic filter. – Tiago A. Mar 13 '19 at 11:23

0 Answers0