Hi guys!
I faced with problem of using httpClient
I send post request to our rest server.
And get this error.
But the most interesting it’s many users don’t have this error and everything is fine.
But couple of users have this problem.
Also they used postman and get fine response from the rest server.
Error: RestApiRequest(POST): url - /auth/login System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error: SecureChannelFailure (Unable to read data from the transport connection: Connection reset by peer.) ---> System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer. ---> System.Net.Sockets.SocketException: Connection reset by peer
--- End of inner exception stack trace ---
at System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.ThrowException (System.Net.Sockets.SocketError error) [0x00000] in <00000000000000000000000000000000>:0
at System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.GetResult (System.Int16 token) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Tasks.ValueTask`1+ValueTaskSourceAsTask+<>c[TResult].<.cctor>b__4_0 (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
at System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.InvokeContinuation (System.Action`1[T] continuation, System.Object state, System.Boolean forceAsync) [0x00000] in <00000000000000000000000000000000>:0
at System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.OnCompleted (System.Net.Sockets.SocketAsyncEventArgs _) [0x00000] in <00000000000000000000000000000000>:0
at System.Net.Sockets.Socket+<>c.<.cctor>b__367_10 (System.IAsyncResult ares) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <00000000000000000000000000000000>:0
--- End of stack trace from previous location where exception was thrown ---
And so deep stacktrace, if it’s needed I will send.
Here is the code of httpClient initialization.
if (_http == null) {
_http = new HttpClient(new HttpClientHandler { SslProtocols = SslProtocols.Tls12 });
_http.DefaultRequestHeaders.Add("User-Agent", $"Unity/{Application.version}");
_http.Timeout = TimeSpan.FromSeconds(30);
}
We are making build with il2cpp (net standard 2.1).
Unity version 2022.3.37f1