quickbird-uk / QuickbirdUWPDashboard

Quickbird UWP App and Server
http://www.quickbird.co.uk/
GNU General Public License v3.0
27 stars 7 forks source link

websocket-related crash #83

Open VladimirAkopyan opened 6 years ago

VladimirAkopyan commented 6 years ago

The app on the tablet crashes sometimes while publishing data, happens every 10 hours or so. The stack-trace form the store says it's related to the web-socket class, which is entirely feasible. stackTrace.txt

VladimirAkopyan commented 6 years ago

Example of crash from the Tablet, compiled to native Log-171007-222244395.zip

VladimirAkopyan commented 6 years ago

Found the bug, by running the app in Visual Studio for a long time: Crash report:

   at Windows.Storage.Streams.DataWriter.DetachStream()
   at Quickbird.Internet.WebSocketConnection.CleanUp()
   at Quickbird.Internet.WebSocketConnection.MessageRecieved(MessageWebSocket sender, MessageWebSocketMessageReceivedEventArgs args)

related code:

private void CleanUp()
{
    _ReconnectTimer?.Dispose();

    try
    {
        _webSocket?.Close(1000, SocketCloseMessage);
    }
    catch (Exception ex)
    {
        LoggingService.LogInfo($"Closing Websocket Failed, {ex.ToString()}", Windows.Foundation.Diagnostics.LoggingLevel.Error);
    }

    _messageWriter?.DetachStream();
    _messageWriter?.Dispose();
    _messageWriter = null;

    _webSocket?.Dispose();
    _webSocket = null;
}   
VladimirAkopyan commented 6 years ago

Need to implement all the errors from https://docs.microsoft.com/en-us/uwp/api/windows.web.weberrorstatus