websocket-sharp icon indicating copy to clipboard operation
websocket-sharp copied to clipboard

Xamarin.iOS Application crash - Mono SslStream throws an exception in Dispose()

Open michaldobrodenka opened this issue 8 years ago • 4 comments

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

michaldobrodenka avatar Feb 17 '17 16:02 michaldobrodenka

hello friend, did you somehow solve this problem?

ilsnk avatar Jul 09 '22 12:07 ilsnk

Hi, to be fair I don't know. I have forked websocket-sharp and keep fixing it. On my github, there is a fork, but I have bunch of fixes not pushed to github, only in my private repo in project I'm working on. I don't pull changes, at least for 4 years. It's difficult because of non standard c# formatting (I get it - mono develop) and no commit messages. If you want, I can put my websocket-sharp code to github. I also made a changes to work in netcore.

michaldobrodenka avatar Jul 13 '22 06:07 michaldobrodenka

@ilsnk I've uploaded all my code, currently using to my fork in https://github.com/michaldobrodenka/websocket-sharp

Forked about 4yrs ago, fixing internally since then

michaldobrodenka avatar Jul 14 '22 13:07 michaldobrodenka

thank you, i will definitely check it out

ilsnk avatar Jul 14 '22 13:07 ilsnk