Closed MatthewTheThomas closed 5 months ago
I am having the same problem using SignalR (which uses WebSockets under ze hood) https://github.com/aspnet/AspNetCore/issues/9362
We're also getting the same issue when cancelling HttpClient requests (SendAsync
/ReadAsync
).
hey team. Any updates on this? I've tested with Mono 6.6 in VS 2019 Preview and I still can see this error.
I am also seeing this with our latest update to Xamarin Android 10 and VS 2019.
We're encountering this one a LOT. I don't know if it's because we're using SignalR and WebSockets or what but I'm really hoping you guys can get this resolved soon. We're using the latest available versions of everything (Xamarin, SignalR client library, etc.)
I'm considering switch to https://github.com/NVentimiglia/Websockets.PCL to avoid this bug. As a understand it, it doesn't use mono MobileAuthenticatedStream.
Even we are facing this issue. Is there any workaround that works? We are seeing this in both VS for Mac 8.4 (buiild 2657) and in VS 16.4.2. Every build of our app in Android (iOS does not have this issue) keeps crashing and there is no way to handle this either.
@ninaada, you can try to use solution provided in https://github.com/ppy/osu-framework/pull/3028.
I have a Xamarin.Forms project, in order to fix it i have subscribed to: TaskScheduler.UnobservedTaskException
and AndroidEnvironment.UnhandledExceptionRaiser
in MainActivity
.
Then i perform check like this:
var canSwallow = ex is AggregateException aggregateException && aggregateException.InnerException is ObjectDisposedException objectDisposedException && objectDisposedException.ObjectName == "MobileAuthenticatedStream";
If canSwallow
is true, then i set e.Handled = true;
in subscribe methods. It prevents app from crashing.
@Feroks Thanks! Will check and see what happens
@Feroks Thanks a ton! it worked :)
I am trying to recreate this fix and am testing using
throw new AggregateException(newObjectDisposedException("MobileAuthenticatedStream"));
while debugging. It seems like this is still crashing? Are you subscribing in your MainActivity.OnCreate()?
With support for Classic Xamarin.Android ended May 1st, 2024, this issue is likely no longer relevant.
If this still persists in .NET 8+, please open a new issue with updated information based on net8.0-android
or greater. Please include a link to this issue for context.
This bug seems to be no longer relevant, we had a lot of crashes like this until we migrated to net7-android
Steps to Reproduce
GC.Collect()
) -- to force the UnobservedTaskExceptionRepro project : WebsocketUnobservedTaskException.zip
Expected Behavior
Expect behavior would not to have an UnobservedTaskException when canceling a websocket during send/recieve
Actual Behavior
Actual behavior is that there is an UnobservedTaskException when canceling a websocket during send/recieve
Version Information
Log File