mixpanel / mixpanel-unity

Official Unity Tracking Library for Mixpanel Analytics
https://mixpanel.com
Apache License 2.0
45 stars 38 forks source link

[Mixpanel] There was an error sending the request. System.AggregateException: One or more errors occurred. #106

Closed Inspekt2 closed 3 years ago

Inspekt2 commented 4 years ago

Issue occurs when WorkerThread(_bgThread) is enabled. If it is disabled, it's fine. So I think that problem happens in this part of the code: var content = new StringContent("data=" + payload, Encoding.UTF8, "application/json"); var responseRequest = _client.PostAsync(url, content).Result; responseCode = (int) responseRequest.StatusCode; response = responseRequest.Content.ReadAsStringAsync().Result;

We had an experiment: we created an empty project and we were trying to reproduce this issue, but it was working without any error. So it seems like it needs some special conditions for reproducing.

Our environment: Unity 2019.2.17f1 Mixpanel V2.2.0 Scripting Backend: IL2CPP APi compatiblity: .NET 4.x

[Mixpanel] There was an error sending the request: System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error: TrustFailure (One or more errors occurred.) ---> System.AggregateException: One or more errors occurred. ---> System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> Mono.Security.Interface.TlsException: Handshake failed - error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED at Mono.Unity.Debug.CheckAndThrow (Mono.Unity.UnityTls+unitytls_errorstate errorState, Mono.Unity.UnityTls+unitytls_x509verify_result verifyResult, System.String context, Mono.Security.Interface.AlertDescription defaultAlert) [0x00036] in :0 at Mono.Unity.UnityTlsContext.ProcessHandshake () [0x00082] in :0 at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status) [0x0003e] in :0 at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus) at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00006] in :0 at Mono.Net.Security.AsyncProtocolRequest+d24.MoveNext () [0x000ff] in :0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0 at Mono.Net.Security.AsyncProtocolRequest+d23.MoveNext () [0x0008b] in :0 --- End of inner exception stack trace --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <567df3e0919241ba98db88bec4c6696f>:0 at Mono.Net.Security.MobileAuthenticatedStream+d47.MoveNext () [0x00254] in :0 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Threading.Tasks.Task.Wait () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0 at Mono.Net.Security.MobileAuthenticatedStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, System.Boolean checkCertificateRevocation) [0x0000d] in :0 at Mono.Net.Security.MonoTlsStream.CreateStream (System.Byte[] buffer) [0x0007b] in :0 at System.Net.WebConnection.CreateStream (System.Net.HttpWebRequest request) [0x00073] in :0 --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetRequestStream (System.IAsyncResult asyncResult) [0x0003a] in :0 at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <567df3e0919241ba98db88bec4c6696f>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Net.Http.HttpClientHandler+d64.MoveNext () [0x002e7] in <7ebf3529ba0e4558a5fa1bc982aa8605>:0 --- End of inner exception stack trace --- at System.Net.Http.HttpClientHandler+d64.MoveNext () [0x00478] in <7ebf3529ba0e4558a5fa1bc982aa8605>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Net.Http.HttpClient+d47.MoveNext () [0x000ca] in <7ebf3529ba0e4558a5fa1bc982aa8605>:0 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Threading.Tasks.Task1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Threading.Tasks.Task1[TResult].get_Result () [0x0000f] in <567df3e0919241ba98db88bec4c6696f>:0 at mixpanel.Worker+d__19.MoveNext () [0x00243] in /Users/user/game/Assets/Mixpanel/Mixpanel/Worker.cs:300 ---> (Inner Exception #0) System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error: TrustFailure (One or more errors occurred.) ---> System.AggregateException: One or more errors occurred. ---> System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> Mono.Security.Interface.TlsException: Handshake failed - error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED at Mono.Unity.Debug.CheckAndThrow (Mono.Unity.UnityTls+unitytls_errorstate errorState, Mono.Unity.UnityTls+unitytls_x509verify_result verifyResult, System.String context, Mono.Security.Interface.AlertDescription defaultAlert) [0x00036] in :0 at Mono.Unity.UnityTlsContext.ProcessHandshake () [0x00082] in :0 at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status) [0x0003e] in :0 at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus) at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00006] in :0 at Mono.Net.Security.AsyncProtocolRequest+d24.MoveNext () [0x000ff] in :0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0 at Mono.Net.Security.AsyncProtocolRequest+d23.MoveNext () [0x0008b] in :0 --- End of inner exception stack trace --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <567df3e0919241ba98db88bec4c6696f>:0 at Mono.Net.Security.MobileAuthenticatedStream+d47.MoveNext () [0x00254] in :0 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Threading.Tasks.Task.Wait () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0 at Mono.Net.Security.MobileAuthenticatedStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, System.Boolean checkCertificateRevocation) [0x0000d] in :0 at Mono.Net.Security.MonoTlsStream.CreateStream (System.Byte[] buffer) [0x0007b] in :0 at System.Net.WebConnection.CreateStream (System.Net.HttpWebRequest request) [0x00073] in :0 --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetRequestStream (System.IAsyncResult asyncResult) [0x0003a] in :0 at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <567df3e0919241ba98db88bec4c6696f>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Net.Http.HttpClientHandler+d64.MoveNext () [0x002e7] in <7ebf3529ba0e4558a5fa1bc982aa8605>:0 --- End of inner exception stack trace --- at System.Net.Http.HttpClientHandler+d64.MoveNext () [0x00478] in <7ebf3529ba0e4558a5fa1bc982aa8605>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0 at System.Net.Http.HttpClient+d47.MoveNext () [0x000ca] in <7ebf3529ba0e4558a5fa1bc982aa8605>:0 <--- UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[]) UnityEngine.Debug:LogError(Object) mixpanel.Mixpanel:LogError(String) (at Assets/Mixpanel/Mixpanel/Log.cs:19) mixpanel.d__19:MoveNext() (at Assets/Mixpanel/Mixpanel/Worker.cs:306) mixpanel.Worker:DispatchOperations() (at Assets/Mixpanel/Mixpanel/Worker.cs:241) mixpanel.Worker:RunBackgroundThread() (at Assets/Mixpanel/Mixpanel/Worker.cs:211) System.Threading.ThreadHelper:ThreadStart()

patedit commented 4 years ago

Hi @Inspekt2 ! Are you modifying the API endpoint? If you go into Edit -> Project Settings -> Mixpanel what do you see under API Host Address? Could you also enable Show Debug under that screen and paste here the output that you see? Thank you!

zihejia commented 3 years ago

We have released v3.0.0 which refactored the persistence layer and will no longer have this problem. please feel free to reopen if you find any issues.