Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP request fails even if the connection is active

I'm facing a problem with an http request done in HTTP.java.

On desktop all works fine (that request is not performed because it's necessary only on Android).

In Android all works without that http request.

After that that http request is made, all others fail after timeout with UnknownHostException error, as if they no longer have access to the internet connection, even if it is active. Also after minutes and after the onResume all http requests fail. Although the app cannot get an http response, the AdMob ad appears in my App, so I think that probably the connection works (or does the AdMob library cache some ads and show them when needed?).

Often, in these cases sometimes it works again:

  • uninstalling and reinstalling the App from Android Studio
  • closing the App, waiting some minutes and reopening it
  • clearing App data from the device
  • waiting an undefined amount of time

After several attempts I discovered that as soon as the problem occurs, almost every time, if I activate the airplane mode and then disable it, the data connection is deactivated and then reactivated, and the App can immediately execute all subsequent http requests without having to do anything else on your device and without even having to reopen the application.

  • tested with wifi on a 1GB fibra network: same error
  • I checked the connection: it is stable, in wifi and also with SIM
  • in the manifest there is the permission for using internet (otherwise it would never have worked)
  • at the same time, the same App on desktop works perfectly and at the best speed, receiving http responses in less than 1 second, so the server isn't the problem
  • I tested also with the url https://www.google.it: same error, the same url is reachable in the device via browser in less than 1 second
  • as in the line .timeout(10000) I'm using a timeout of 10 seconds, the server has timeout set to 60 seconds
  • checked the server SSL "quality" at https://www.ssllabs.com/ssltest: got "A" in "Overall Rating"
  • done the SIM "reboot" directly with a Vodafone operator

I'm testing on a real device with a flat 4G connection and with wifi, with "NetGuard - no-root firewall" VPN App installed.

This VPN works very well with all the other apps and probably mine too, but I can't rule out that it's the problem, although I hardly think it is (I use it since years without problems).

There is something wrong in my code? Or at least, how can I know the exact cause of this error?

Thanks.

AndroidLauncher.java:

@Override
protected void onCreate (Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ...

    // Create the layout
    RelativeLayout layout = new RelativeLayout(this);

    // Do the stuff that initialize() would do for you
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

    // Add the libGDX view
    game = new MyGame(this);
    gameView = initializeForView(game);
    layout.addView(gameView);

    // Add the AdMob view
    RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    adParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    layout.addView(mAdView, adParams);

    layout.setKeepScreenOn(true);

    setContentView(layout);
}

MyGame.java:

public class MyGame extends Game {
    public void create() {
    
    ...

    java.security.Security.setProperty("networkaddress.cache.ttl" , "0");

    this.setScreen(new MainMenuScreen(this));
}

MainMenuScreen.java:

public MainMenuScreen(final MyGame game) {
    ... 
    
    performHttpRequest(baseUrl, getData, true, myListener);
}

HTTP.java:

public class HTTP {
    public static void performHttpRequest(String baseUrl, String q, Net.HttpResponseListener httpResponseListener) {
        HttpRequestBuilder requestBuilder = new HttpRequestBuilder();
        Net.HttpRequest httpRequest = requestBuilder.newRequest()
            .method(Net.HttpMethods.GET)
            .url(baseUrl)
            .content(q)
            .timeout(10000)
            .build();
        Gdx.net.sendHttpRequest(httpRequest, httpResponseListener);
    }
}

build.gradle (module android):

...
buildTypes {
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            debuggable true
        }
    }
...

build.gradle (project):

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://plugins.gradle.org/m2/" }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.1'
    }
}

allprojects {
    apply plugin: "eclipse"

    version = '1.0'
    ext {
        appName = "MyAppName"
        gdxVersion = '1.9.13'
        roboVMVersion = '2.3.8'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.7.0'
        aiVersion = '1.8.0'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        jcenter()
        google()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}

project(":desktop") {
    apply plugin: "java-library"

    dependencies {
        implementation project(":core")
        api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
        api "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
    }
}

project(":android") {
    apply plugin: "android"

    configurations { natives }

    dependencies {
        implementation project(":core")
        api "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
        api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
        api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
        api "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86_64"
        implementation 'com.google.android.gms:play-services-ads:19.6.0'
        implementation 'com.google.android.gms:play-services-basement:17.5.0'
    }
}

project(":core") {
    apply plugin: "java-library"

    dependencies {
        api "com.badlogicgames.gdx:gdx:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
    }
}

Logcat:

I/System.out: failed to connect to myDomain.app/NN.NN.NN.NN (port 443) from /10.NN.NN.NN (port 41326) after 10000ms
W/System.err: java.net.SocketTimeoutException: failed to connect to myDomain.app/NN.NN.NN.NN (port 443) from /10.NN.NN.NN (port 41326) after 10000ms
        at libcore.io.IoBridge.connectErrno(IoBridge.java:191)
        at libcore.io.IoBridge.connect(IoBridge.java:135)
        at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
        at java.net.Socket.connect(Socket.java:621)
        at com.android.okhttp.internal.Platform.connectSocket(Platform.java:182)
        at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:1407)
        at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:1359)
        at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:221)
        at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:144)
        at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:106)
W/System.err:     at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:400)
        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:333)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:483)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:135)
        at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:90)
        at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:30)
        at com.badlogic.gdx.net.NetJavaImpl$2.run(NetJavaImpl.java:223)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)

(I removed the libGDX tag because it seems Android related, because the method is only invoked from the MainMenuScreen class through the interface, but executed in the Android activity)

adb logcat *:E as suggested by Always Learning in a comment, the log is from the App opening to the end of the http request:

cognitionService: handleMessage: event 200 value : 1
02-23 19:39:55.336  5803  5803 E libprocessgroup: set_timerslack_ns write failed: Operation not permitted
02-23 19:39:55.347  5803  5803 E libprocessgroup: set_timerslack_ns write failed: Operation not permitted
02-23 19:39:57.163  4987  5272 E ActivityTaskManager: TouchDown intent received, starting ActiveLaunch
02-23 19:39:57.205  4987  5041 E system_server: Invalid ID 0x00000000.
02-23 19:39:57.212 12157 12157 E .myAppName: Unknown bits set in runtime_flags: 0x8000
02-23 19:39:57.233  4987  5041 E DecorView: mWindow.mActivityCurrentConfig is null
02-23 19:39:57.281  4500  4613 E BufferQueueProducer: [com.sec.android.app.launcher/com.sec.android.app.launcher.activities.LauncherActivity$_5803#0] disconnect: not connected (req=1)
02-23 19:39:57.281  5803  7530 E OpenGLRenderer: ReliableSurface: perform returned an error
02-23 19:39:57.295  4987  5234 E PkgPredictorService-Collector: record changed bt=0  wifi=0 screen=0
02-23 19:39:57.932 14641 14641 E webview_servic: Not starting debugger since process cannot load the jdwp agent.
02-23 19:39:57.935  4987  5540 E PackageManager: Failed to find package; permName: android.permission.INTERNET, uid: 99774, caller: 1000
02-23 19:39:57.962 14661 14661 E ocessService0:: Not starting debugger since process cannot load the jdwp agent.
02-23 19:39:58.627  4987  5307 E WindowManager: win=Window{5a5aa90 u0 com.sec.android.app.launcher/com.sec.android.app.launcher.activities.LauncherActivity} destroySurfaces: appStopped=true win.mWindowRemovalAllowed=false win.mRemoveOnExit=false win.mViewVisibility=8 caller=com.android.server.wm.AppWindowToken.destroySurfaces:1248 com.android.server.wm.AppWindowToken.destroySurfaces:1229 com.android.server.wm.AppWindowToken.notifyAppStopped:1284 com.android.server.wm.ActivityRecord.activityStoppedLocked:2776 com.android.server.wm.ActivityTaskManagerService.activityStopped:2512 android.app.IActivityTaskManager$Stub.onTransact:2288 android.os.Binder.execTransactInternal:1056 
02-23 19:39:58.708  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:39:58.728  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:39:58.775  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:39:58.923  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:39:58.924  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:39:58.981  4987  5041 E WindowManager: win=Window{b1dc417 u0 Splash Screen my.package.name EXITING} destroySurfaces: appStopped=false win.mWindowRemovalAllowed=true win.mRemoveOnExit=true win.mViewVisibility=0 caller=com.android.server.wm.AppWindowToken.destroySurfaces:1248 com.android.server.wm.AppWindowToken.destroySurfaces:1229 com.android.server.wm.WindowState.onExitAnimationDone:5189 com.android.server.wm.WindowStateAnimator.onAnimationFinished:320 com.android.server.wm.WindowState.onAnimationFinished:5630 com.android.server.wm.-$$Lambda$yVRF8YoeNdTa8GR1wDStVsHu8xM.run:2 com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$0$SurfaceAnimator:100 
02-23 19:39:59.120 12157 12157 E libc    : Access denied finding property "ro.serialno"
02-23 19:39:59.354  4447  4447 E audit   : type=1400 audit(1614105599.351:37597): avc:  denied  { write } for  pid=12157 comm="Thread-12" name="perfd" dev="sda32" ino=35421 scontext=u:r:untrusted_app:s0:c112,c257,c512,c768 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=0 SEPF_SM-M315F_10_0024 audit_filtered
02-23 19:39:59.354  4447  4447 E audit   : type=1300 audit(1614105599.351:37597): arch=c00000b7 syscall=48 success=no exit=-13 a0=ffffff9c a1=7b243f7ec1 a2=2 a3=0 items=0 ppid=4460 pid=12157 auid=... uid=10368 gid=10368 euid=10368 suid=10368 fsuid=10368 egid=10368 sgid=10368 fsgid=10368 tty=(none) ses=... comm="Thread-12" exe="/system/bin/app_process64" subj=u:r:untrusted_app:s0:c112,c257,c512,c768 key=(null)
02-23 19:39:59.354  4447  4447 E audit   : type=1327 audit(1614105599.351:37597): proctitle="my.package.name"
02-23 19:39:59.860  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:40:00.275  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:40:00.910 29776 14898 E memtrack: Couldn't load memtrack module
02-23 19:40:01.889  4500  4613 E BufferQueueProducer: [Toast$_12157#0] disconnect: not connected (req=1)
02-23 19:40:01.889 12157 14616 E OpenGLRenderer: ReliableSurface: perform returned an error
02-23 19:40:05.264  4987  5166 E MotionRecognitionService: handleMessage: event 200 value : 1
02-23 19:40:05.861  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:40:06.165  4987  5049 E NotificationService: Suppressing notification from package by user request.
02-23 19:40:06.272  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:40:09.116  4987  5043 E Watchdog: !@Sync: 19566 heap: 96 / 119 [2021-02-23 19:40:09.116] sdogWay: softdog
02-23 19:40:15.247  4987  5166 E MotionRecognitionService: handleMessage: event 200 value : 1
02-23 19:40:16.486  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:40:16.490  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:40:16.512  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:40:16.533  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:40:17.865  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:40:18.274  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:40:21.181  4987  5049 E NotificationService: Suppressing notification from package by user request.
02-23 19:40:25.335  4987  5166 E MotionRecognitionService: handleMessage: event 200 value : 1
02-23 19:40:30.587  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:40:30.616 12157 12157 E Ads     : JS: Uncaught ReferenceError: OmidCreativeSession is not defined (https://googleads.g.doubleclick.net/mads/gma?caps=inlineVideo_interactiveVideo_mraid1_mraid2_mraid3_sdkVideo_exo3_th_autoplay_mediation_scroll_av_av_transparentBackground_sdkAdmobApiForAds_di_aso_sfv_dinm_dim_nav_navc_dinmo_ipdof_gls_gcache_saiMacro_xSeconds&eid=...)
02-23 19:40:30.658 12157 12157 E Ads     : JS: Uncaught ReferenceError: OmidCreativeSession is not defined (https://googleads.g.doubleclick.net/mads/gma?caps=mraid1_mraid2_mraid3_th_mediation_scroll_av_av_transparentBackground_sdkAdmobApiForAds_di_aso_dinm_dim_dinmo_ipdof_gls_saiMacro_xSeconds&eid=...)
02-23 19:40:31.277  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:40:31.437  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:40:35.380  4987  5166 E MotionRecognitionService: handleMessage: event 200 value : 1
02-23 19:40:36.199  4987  5049 E NotificationService: Suppressing notification from package by user request.
02-23 19:40:36.586  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:40:37.279  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:40:37.443  4459  4647 E Netd    : getNetworkForDns: getNetId from enterpriseCtrl is netid 0
02-23 19:40:39.129  4987  5043 E Watchdog: !@Sync: 19567 heap: 87 / 110 [2021-02-23 19:40:39.129] sdogWay: softdog

Edit 1 ---------------------------------------------------------:

I just performed the SIM "reboot" directly with a Vodafone operator, so now I should exclude a SIM problem.

Some info while the http request fails in the MainMenuScreen but the AdMod ad is displayed and also all works fine in firefox:

activeNetwork.toString()           = 601
activeNetwork.describeContents()   = 0
activeNetworkInfo.getReason()      = null
activeNetworkInfo.getType()        = 0
activeNetworkInfo.getTypeName()    = MOBILE
activeNetworkInfo.getSubtype()     = 13
activeNetworkInfo.getSubtypeName() = LTE
activeNetworkInfo.getExtraInfo()   = mobile.vodafone.it
activeNetworkInfo.toString()       = [
    type:        MOBILE[LTE]
    , state:     CONNECTED/CONNECTED
    , reason:    (unspecified)
    , extra:     mobile.vodafone.it
    , failover:  false
    , available: true
    , roaming:   false
]

The errors:

W/System.err: java.net.SocketTimeoutException: SSL handshake timed out
W/System.err:     at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
        at com.android.org.conscrypt.NativeSsl.doHandshake(NativeSsl.java:387)
        at com.android.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(ConscryptFileDescriptorSocket.java:234)
        at com.android.okhttp.internal.io.RealConnection.connectTls(RealConnection.java:1471)
        at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:1415)
        at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:1359)
        at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:221)
        at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:144)
        at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:106)
        at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:400)
        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:333)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:483)
W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:135)
        at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:90)
        at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:30)
        at com.badlogic.gdx.net.NetJavaImpl$2.run(NetJavaImpl.java:223)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)

W/System.err: javax.net.ssl.SSLHandshakeException: SSL handshake aborted: ssl=0x7021beca08: I/O error during system call, Connection reset by peer
        at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
W/System.err:     at com.android.org.conscrypt.NativeSsl.doHandshake(NativeSsl.java:387)
        at com.android.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(ConscryptFileDescriptorSocket.java:234)
        at com.android.okhttp.internal.io.RealConnection.connectTls(RealConnection.java:1471)
        at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:1415)
        at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:1359)
        at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:221)
        at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:144)
        at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:106)
        at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:400)
        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:333)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:483)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:135)
        at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:90)
        at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:30)
        at com.badlogic.gdx.net.NetJavaImpl$2.run(NetJavaImpl.java:223)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)

My solution:

Uninstall the VPN App.

It was such a simple solution ... I would not have imagined it was the App's fault for the VPN, I considered it foolproof having used it for over 3 years ...

If this hadn't been the problem, your suggestions would certainly have been helpful and probably decisive, thank you all! (unfortunately I cannot purposely give the bounty reward to multiple users, but I can upvote your answer)

like image 413
user2342558 Avatar asked Feb 21 '21 14:02

user2342558


People also ask

How is a HTTP connection established?

Establishing a connection Opening a connection in HTTP means initiating a connection in the underlying transport layer, usually this is TCP. With TCP the default port, for an HTTP server on a computer, is port 80. Other ports can also be used, like 8000 or 8080.

What are the HTTP request methods?

The most commonly used HTTP request methods are GET, POST, PUT, PATCH, and DELETE. These are equivalent to the CRUD operations (create, read, update, and delete). GET: GET request is used to read/retrieve data from a web server.

Which request header will continue the client's session?

The HTTP keep-alive header maintains a connection between a client and your server, reducing the time needed to serve files.


2 Answers

That error maybe relate to VPN connect, please close the application, off VNP if it was connected, re-connect to VPN and restart you application.

In all case, you must be connect the VPN before open the application.

like image 102
vertex2707 Avatar answered Oct 24 '22 19:10

vertex2707


The UnknownHostException means that it was unable to resolve the hostname. This is normal (from time to time) with slow or unstable network connections. However, Java is aggressive at caching DNS responses. The reason it does not work until you reinstall the app is that the bad DNS response was cached, so all subsequent calls fail. Changing the DNS cache ttl in your java app should fix it:

 networkaddress.cache.ttl = 0
 networkaddress.cache.negative.ttl = 0

In this case it's the negative.ttl setting you want -- subsequent lookups will be bypassed until that time has elapsed. But it's a good idea to set both properties to low values.

More details here: How to make Java honor the DNS Caching Timeout?

like image 28
Nicholas Rees Avatar answered Oct 24 '22 18:10

Nicholas Rees