[Android] Javax.Net.Ssl.SSLException help

Stesvis 1,041 Reputation points
2021-04-21T21:09:08.127+00:00

About one every 10 times that I launch my app it crashes just after the splash screen (on the first http request attempt) because of a:

Javax.Net.Ssl.SSLException: Read error: ssl=0xc4c54648: I/O error during system call, Connection reset by peer

I retrieved the full stack trace and description from App Center and this is what I see:

Java.Interop
JniEnvironment+InstanceMethods.CallIntMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args)
Java.Interop
JniPeerMembers+JniInstanceMethods.InvokeVirtualInt32Method (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters)
Java.Net
HttpURLConnection.get_ResponseCode () /Users/builder/azdo/_work/278/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-30/mcw/Java.Net.HttpURLConnection.cs:511
Xamarin.Android.Net
AndroidClientHandler+<>c__DisplayClass46_0.<DoProcessRequest>b__2 () /Users/builder/azdo/_work/278/s/xamarin-android/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs:439
System.Threading.Tasks
Task1[TResult].InnerInvoke () /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs:534 System.Threading.Tasks Task.Execute () /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319 Xamarin.Android.Net AndroidClientHandler.DoProcessRequest (System.Net.Http.HttpRequestMessage request, Java.Net.URL javaUrl, Java.Net.HttpURLConnection httpConnection, System.Threading.CancellationToken cancellationToken, Xamarin.Android.Net.AndroidClientHandler+RequestRedirectionState redirectState) /Users/builder/azdo/_work/278/s/xamarin-android/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs:439 Xamarin.Android.Net AndroidClientHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) /Users/builder/azdo/_work/278/s/xamarin-android/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs:287 System.Net.Http HttpClient.FinishSendAsyncBuffered (System.Threading.Tasks.Task1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:506
YouRent.Mobile.Services.APIs.Misc
ApiWrapperService.PostOrPut[T] (System.String url, System.String payload, System.Net.Http.HttpMethod method, System.Boolean requiresToken, System.Boolean encode) R:\Levitica\YouRent\YouRent.Mobile\YouRent.Mobile\Services\APIs\Misc\ApiWrapperService.cs:329
YouRent.Mobile.Services.APIs.Misc
ApiWrapperService.Post[T] (System.String url, System.Object postData, System.Boolean requiresToken, System.Boolean encode) R:\Levitica\YouRent\YouRent.Mobile\YouRent.Mobile\Services\APIs\Misc\ApiWrapperService.cs:160
javax.net.ssl.SSLException: Read error: ssl=0xc4c54648: I/O error during system call, Connection reset by peer
com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
com.android.org.conscrypt.NativeSsl.read NativeSsl.java:399
com.android.org.conscrypt.ConscryptFileDescriptorSocket$SSLInputStream.read ConscryptFileDescriptorSocket.java:546
com.android.okhttp.okio.Okio$2.read Okio.java:136
com.android.okhttp.okio.AsyncTimeout$2.read AsyncTimeout.java:211
com.android.okhttp.okio.RealBufferedSource.indexOf RealBufferedSource.java:306
com.android.okhttp.okio.RealBufferedSource.indexOf RealBufferedSource.java:300
com.android.okhttp.okio.RealBufferedSource.readUtf8LineStrict RealBufferedSource.java:196
com.android.okhttp.internal.http.Http1xStream.readResponse Http1xStream.java:186
com.android.okhttp.internal.http.Http1xStream.readResponseHeaders Http1xStream.java:127
com.android.okhttp.internal.http.HttpEngine.readNetworkResponse HttpEngine.java:737
com.android.okhttp.internal.http.HttpEngine.readResponse HttpEngine.java:609
com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute HttpURLConnectionImpl.java:471
com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse HttpURLConnectionImpl.java:407
com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode HttpURLConnectionImpl.java:538
com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode DelegatingHttpsURLConnection.java:105
com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode HttpsURLConnectionImpl.java:26

I am not sure if it's a problem with the app, with Android itself, or with the backend (ASPNET Core 5 running on IIS).

I couldn't find any real useful solution on google. It happens randomly but averaging 1 very 10 times i launch the app. After the crash, the very next time i launch it it always works fine.
Every line of code "apparently" throwing the exception is inside a try/catch and yet, it crashes.

Does anybody know where to start? Never seen this issue in iOS.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,305 questions
{count} votes