locked
HubConnection.Error fired and kill the uwp app RRS feed

  • Question

  • User-965037737 posted

    Hi all,

    We have a big problem with SignalR for UWP app and we cannot figure out what the reason is.

    What we have :

    • UWP Client in C# that connects at startup to a server with SignalR
    • A server with SignalR, MobileServices and WebApi

    Our problem :

    Randomly, the client crashs totally and there's no understandable error that can explain why. We just know that we pass into the Error event on the HubConnexion in the client and even if we put a breakpoint at this point, the programm crashs and visual studio doesn't break.

    The error that appears in the console looks like this :

    [SIGNALR] 13:14:27.2402369 - 9298e64b-30d3-4630-8b43-a451fcc9b296 - SSE: OnMessage(Data: {})
    Exception thrown: 'System.Exception' in mscorlib.ni.dll
    Exception thrown: 'System.IO.IOException' in mscorlib.ni.dll
    Exception thrown: 'System.IO.IOException' in mscorlib.ni.dll
    'Echino.ClientMicrosoftDevLocal.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Workspace\Echino (FF5)\EchinoDevelopment\Echino.ClientMicrosoftDevLocal\bin\x86\Debug\AppX\System.Net.Requests.dll'. Cannot find or open the PDB file.
    13:14:31.9284526 - 9298e64b-30d3-4630-8b43-a451fcc9b296 - OnError(System.Exception: Exception from HRESULT: 0x80072EFF
    [SIGNALR] 13:14:31.9284526 - 9298e64b-30d3-4630-8b43-a451fcc9b296 - OnError(System.Exception: Exception from HRESULT: 0x80072EFF
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    [SIGNALR]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    [SIGNALR]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
    [SIGNALR]    at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
       at System.IO.WinRtToNetFxStreamAdapter.<ReadAsyncInternal>d__1.MoveNext())
    [SIGNALR]    at System.IO.WinRtToNetFxStreamAdapter.<ReadAsyncInternal>d__1.MoveNext())
    --- signalR error ---------------------------------------------
                Exception : 
                    EX:         Exception from HRESULT: 0x80072EFF 
                    SOURCE:     mscorlib
                    STACKTRACE:    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
       at System.IO.WinRtToNetFxStreamAdapter.<ReadAsyncInternal>d__1.MoveNext() 
                    HRESULT:    -2147012865 
    
                InnerException : 
                    EX:         null 
                    SOURCE:     null 
                    STACKTRACE: null 
                    HRESULT:     
    
                BaseException : 
                    EX:         Exception from HRESULT: 0x80072EFF
                    SOURCE:     mscorlib
                    STACKTRACE:    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
       at System.IO.WinRtToNetFxStreamAdapter.<ReadAsyncInternal>d__1.MoveNext(),
                    HRESULT:    -2147012865 
    
                
    The program '[31328] iisexpress.exe' has exited with code -1073741816 (0xc0000008) 'An invalid handle was specified'.
    The program '[31328] iisexpress.exe: Program Trace' has exited with code 0 (0x0).
    The program '[264] Echino.ClientMicrosoftDevLocal.exe: Program Trace' has exited with code 0 (0x0).
    The program '[264] Echino.ClientMicrosoftDevLocal.exe' has exited with code -1 (0xffffffff).

    The code to connect to the server seeems right :

    public void InitHub()
            {
                if (_isInit)
                    return;
    
                _isInit = true;
    
                _clientConfiguration = ControllerManager.Instance.ClientConfiguration;
                _connection = new HubConnection(_clientConfiguration.ServeurHostURL);
    
                _connection.Headers.Add("X-ZUMO-AUTH", ControllerManager.Instance.AccessToken);
                
    #if DEBUG
                if (EnableSignalRLog)
                {
                    _connection.TraceLevel = TraceLevels.All;
                    _connection.TraceWriter = new DebugTextWriter("signalR");
                }
    #endif
                _activityProxy = _connection.CreateHubProxy("ActivityHub");
                _jobActivityProxy = _connection.CreateHubProxy("WebJobHub");
            }
    
            public override async Task Connect()
            {
                InitHub();
    
                _activityProxy.On("ActivityReceived", (string message) =>
                {
                    if (message != null)
                    {
                        ActivityMessage activityMessage = JsonConvert.DeserializeAnonymousType<ActivityMessage>(message, new ActivityMessage());
                        OnActivityEvent(activityMessage);
                    }
                });
    
                _jobActivityProxy.On("JobActivityReceived", (string message) =>
                {
                    try
                    {
                        if (message != null)
                        {
                            JobActivityMessage jobActivityMessage =
                                JsonConvert.DeserializeAnonymousType<JobActivityMessage>(message, new JobActivityMessage());
                            ScreenDebug.Instance.Log(jobActivityMessage.ToString(), "JobActivityReceived");
                            OnJobActivityEvent(jobActivityMessage);
                        }
                    }
                    catch (Exception e)
                    {
                        ScreenDebug.Instance.Failed($"Error in JobActivityReceived {e.Message}", "signalr");
                    }
    
                });
    
                _connection.Error += exception =>
                {
                    // breakpoint does not hit here but the error is shown in the console, how can it be possible ? 
                    try
                    {
                        var innerEx = exception?.InnerException;
                        var baseEx = exception?.GetBaseException();
    
    
                        ScreenDebug.Instance.Failed(
                            $@"--- signalR error ---------------------------------------------
                Exception : 
                    EX:         {exception
                                ?.Message ?? "null"} 
                    SOURCE:     {exception?.Source ?? "null"}
                    STACKTRACE: {exception
                                    ?.StackTrace ?? "null"} 
                    HRESULT:    {exception?.HResult} 
    
                InnerException : 
                    EX:         {innerEx
                                        ?.Message ?? "null"} 
                    SOURCE:     {innerEx?.Source ?? "null"} 
                    STACKTRACE: {innerEx
                                            ?.StackTrace ?? "null"} 
                    HRESULT:    {innerEx?.HResult} 
    
                BaseException : 
                    EX:         {baseEx
                                                ?.Message ?? "null"}
                    SOURCE:     {baseEx?.Source ?? "null"}
                    STACKTRACE: {baseEx
                                                    ?.StackTrace ?? "null"},
                    HRESULT:    {baseEx?.HResult} 
    
                ");
    
                    }
                    catch (Exception e)
                    {
                        
                    }
                   
                };
    
                _connection.StateChanged += change =>
                {
                    ScreenDebug.Instance.Log($"CONNEXION State Changed to {change.NewState}", "signalr");
                };
                _connection.Closed += async () =>
                {
                    await _connection.Start();
                    ScreenDebug.Instance.Log("CONNEXION Closed", "signalr");
                };
                _connection.ConnectionSlow += () =>
                {
                    ScreenDebug.Instance.Failed("Timeout (connection slow)", "signalr");
                };
                _connection.Reconnecting += () =>
                {
                    ScreenDebug.Instance.Failed("Reconnecting...", "signalr");
                };
                _connection.Reconnected += () =>
                {
                    ScreenDebug.Instance.Success("Reconnected !", "signalr");
                };
    
                ScreenDebug.Instance.Log($"DeadlockErrorTimeout duration : {_connection.DeadlockErrorTimeout.Seconds}seconds", "signalr");
                ScreenDebug.Instance.Log($"TransportConnectTimeout duration : {_connection.TransportConnectTimeout.Seconds}seconds", "signalr");
    
                await _connection.Start(new ServerSentEventsTransport());
    
            }

    Does somebody have any idea of what that can be ?

    Many thanks in advance and all replies are welcome

    UPDATE 1 :

    We also take a look at the logs server side and the following error appears :

    SignalR.Transports.TransportHeartBeat Verbose: 0 : KeepAlive(60a1f55c-c4f5-4648-b33e-496bf02eca4c)
    SignalR.Transports.WebSocketTransport Error: 0 : OnError(60a1f55c-c4f5-4648-b33e-496bf02eca4c, System.Net.WebSockets.WebSocketException (0x800703E3): L’opération d’entrée/sortie a été abandonnée en raison de l’arrêt d’un thread ou à la demande d’une application
       à System.Web.WebSockets.WebSocketPipe.<>c__DisplayClass9_0.<ReadFragmentAsync>b__0(Int32 hrError, Int32 cbIO, Boolean fUtf8Encoded, Boolean fFinalFragment, Boolean fClose)
    --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
       à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       à System.Web.WebSockets.AspNetWebSocket.<DoWork>d__45`1.MoveNext()
    --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
       à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       à System.Web.WebSockets.AspNetWebSocket.<>c__DisplayClass36_0.<<ReceiveAsyncImpl>b__0>d.MoveNext()
    --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
       à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       à System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
       à Microsoft.AspNet.SignalR.TaskAwaiterHelper.PreserveCultureAwaiter`1.GetResult()
       à Microsoft.AspNet.SignalR.WebSockets.WebSocketMessageReader.<ReadMessageAsync>d__3.MoveNext()
    --- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
       à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       à System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
       à Microsoft.AspNet.SignalR.TaskAwaiterHelper.PreserveCultureAwaiter`1.GetResult()
       à Microsoft.AspNet.SignalR.WebSockets.WebSocketHandler.<ProcessWebSocketRequestAsync>d__25.MoveNext())
    SignalR.Transports.WebSocketTransport Information: 0 : CloseSocket(60a1f55c-c4f5-4648-b33e-496bf02eca4c)
    SignalR.Transports.TransportHeartBeat Verbose: 0 : 60a1f55c-c4f5-4648-b33e-496bf02eca4c is dead
    

    Maybe somebody have already seen this ?

    Friday, April 8, 2016 2:34 PM

All replies