Xamarin.iOS Application crash - Mono SslStream throws an exception in Dispose()
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.1k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
Sometimes when changing wifi/4G on iPhone app crashes because in WebSocket.cs in releaseClientResources is called _stream.Dispose(); and Dispose throws an Exception.
Swallowing exception helped. I don't know how to handle it better.
Unable to write data to the transport connection: The socket has been shut down. (System.IO.IOException)
at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x000e8] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.4.0.121/src/mono/mcs/class/referencesource/System/net/System/Net/Sockets/NetworkStream.cs:602
at Mono.Net.Security.MobileAuthenticatedStream.InnerFlush () [0x00011] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.4.0.121/src/mono/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:562
at Mono.Net.Security.MobileAuthenticatedStream.InnerWrite () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.4.0.121/src/mono/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:556
at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (Mono.Net.Security.AsyncOperationStatus status) [0x0006b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.4.0.121/src/mono/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:267
at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation () [0x0000d] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.4.0.121/src/mono/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:218
at Mono.Net.Security.AsyncProtocolRequest.StartOperation () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.4.0.121/src/mono/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:199
--- inner exception ---
The socket has been shut down (System.Net.Sockets.SocketException)
at System.Net.Sockets.Socket.Send (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x0002a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.4.0.121/src/mono/mcs/class/System/System.Net.Sockets/Socket.cs:2383
at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x000b4] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.4.0.121/src/mono/mcs/class/referencesource/System/net/System/Net/Sockets/NetworkStream.cs:591
...
WebSocket.cs
releaseClientResources
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in WebSocket.cs at releaseClientResources and trace the _stream.Dispose() path alongside the reported MobileAuthenticatedStream stack trace. Reproduce a Wi-Fi/4G transition on the iPhone, determine the expected disposal behavior for a shut-down socket, and verify the application no longer crashes during that transition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- mobile-dev, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100