Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xamarin.iOS app crashes with NotImplementedException #222

Closed
alexsorokoletov opened this issue Dec 8, 2017 · 13 comments
Closed

Xamarin.iOS app crashes with NotImplementedException #222

alexsorokoletov opened this issue Dec 8, 2017 · 13 comments
Assignees

Comments

@alexsorokoletov
Copy link
Contributor

Actual Behavior

  1. Run Xamarin.iOS app that sends data to event hub using the SDK, start app on Wi-Fi.
  2. Switch off Wi-Fi, leave LTE/4G on.
  3. App crashes with exception (see stack trace below).

Expected Behavior

  1. App is not crashing and continues to send data.

Versions

  • OS platform and version: Xamarin iOS 10/11
  • .NET Version: Mono 5.
  • NuGet package version or commit ID: 1.0.3/1.10
Xamarin Exception Stack:
System.NotImplementedException: The method or operation is not implemented.
  at System.Net.Sockets.MultipleConnectAsync.InternalConnectCallback (System.Object sender, System.Net.Sockets.SocketAsyncEventArgs args) <0x100a61198 + 0x00270> in <a4d230a362d74681a411a66f6d0be184#144952ab42dcea6e3ed69fcacf2c25f1>:0
  at System.Net.Sockets.SocketAsyncEventArgs.Complete () <0x100a621dc + 0x0002b> in <a4d230a362d74681a411a66f6d0be184#144952ab42dcea6e3ed69fcacf2c25f1>:0
  at System.Net.Sockets.Socket+<>c.<.cctor>b__306_3 (System.IAsyncResult ares) <0x100992db0 + 0x001af> in <a4d230a362d74681a411a66f6d0be184#144952ab42dcea6e3ed69fcacf2c25f1>:0
  at System.Net.Sockets.SocketAsyncResult+<>c.<Complete>b__27_0 (System.Object state) <0x100a628ec + 0x00067> in <a4d230a362d74681a411a66f6d0be184#144952ab42dcea6e3ed69fcacf2c25f1>:0
  at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () <0x1007ed708 + 0x0004f> in <e9a408feb7af4c46b81589c1b3a3e1a6#144952ab42dcea6e3ed69fcacf2c25f1>:0
  at System.Threading.ThreadPoolWorkQueue.Dispatch () <0x100627c20 + 0x001cb> in <e9a408feb7af4c46b81589c1b3a3e1a6#144952ab42dcea6e3ed69fcacf2c25f1>:0
  at ObjCRuntime.Runtime.ThreadPoolDispatcher (System.Func`1[TResult] callback) <0x10090f374 + 0x0003b> in <21d68dce9d574fa1a5570d0bc0bc7703#144952ab42dcea6e3ed69fcacf2c25f1>:0
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () <0x1007ed568 + 0x00067> in <e9a408feb7af4c46b81589c1b3a3e1a6#144952ab42dcea6e3ed69fcacf2c25f1>:0

See similar error in Ably ably/ably-dotnet#161

@serkantkaraca
Copy link
Member

Does it work if you start on cellular data?
Have you changed default transport type on the client?

@alexsorokoletov
Copy link
Contributor Author

@serkantkaraca let me check, default transport is same, Amqp, as in #223.

@alexsorokoletov
Copy link
Contributor Author

@serkantkaraca this issue is reproduced when switching from Wi-Fi to cellular. No problem if we start with cellular at once.

@alexsorokoletov
Copy link
Contributor Author

Additional similar stack trace (leads to this line in Mono https://github.com/mono/mono/blob/master/mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs#L257)

System.NotImplementedException: The method or operation is not implemented.   
  at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationAsyncFailure (System.Exception exception, System.Int32 bytesTransferred, System.Net.Sockets.SocketFlags flags) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.2/src/mono/mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs:257 
  at System.Net.Sockets.MultipleConnectAsync.AsyncFail (System.Exception e) [0x0001a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.2/src/mono/mcs/class/referencesource/System/net/System/Net/Sockets/_MultipleConnectAsync.cs:305 
  at System.Net.Sockets.MultipleConnectAsync.Fail (System.Boolean sync, System.Exception e) [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.2/src/mono/mcs/class/referencesource/System/net/System/Net/Sockets/_MultipleConnectAsync.cs:273 
  at System.Net.Sockets.MultipleConnectAsync.DoDnsCallback (System.IAsyncResult result, System.Boolean sync) [0x000b4] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.2/src/mono/mcs/class/referencesource/System/net/System/Net/Sockets/_MultipleConnectAsync.cs:133 
  at System.Net.Sockets.MultipleConnectAsync.DnsCallback (System.IAsyncResult result) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.2/src/mono/mcs/class/referencesource/System/net/System/Net/Sockets/_MultipleConnectAsync.cs:78 
  at (wrapper managed-to-native) System.Runtime.Remoting.Messaging.AsyncResult:Invoke (System.Runtime.Remoting.Messaging.AsyncResult)
  at System.Runtime.Remoting.Messaging.AsyncResult.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.2/src/mono/mcs/class/corlib/System.Runtime.Remoting.Messaging/AsyncResult.cs:210 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.2/src/mono/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:856 
  at ObjCRuntime.Runtime.ThreadPoolDispatcher (System.Func`1[TResult] callback) [0x00006] in /Users/builder/data/lanes/5665/6857dfcc/source/xamarin-macios/src/ObjCRuntime/Runtime.cs:244 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00009] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.2/src/mono/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1208 

There is an easier repro now - run app that constantly sends data to event hub using AMQP (iOS simulator is okay) and then disconnect from Wi-Fi on the host. Simulator app will crash after short time with this error.

Issue filed in Xamarin Bugzilla by another person https://bugzilla.xamarin.com/show_bug.cgi?id=60772

Similar issue in Websocket4Net kerryjiang/WebSocket4Net#108

@alexsorokoletov
Copy link
Contributor Author

We decided to put to test version where we have TransportType=AmqpWebSockets instead of TransportType=Amqp in our connection string. Will keep you updated about results

@serkantkaraca
Copy link
Member

Thanks Alex. I am checking out our code base to find out why we hit NotImplemented on Mono.

@serkantkaraca
Copy link
Member

Does it fail the same way if you start the app w/o any available network connection? It seems Mono Socket will crash with NotImplementedException if connection attempt fails.

@serkantkaraca
Copy link
Member

serkantkaraca commented Jan 5, 2018

The issue seems to be here: https://github.com/mono/mono/blob/0bcbe39b148bb498742fc68416f8293ccd350fb6/mcs/class/referencesource/System/net/System/Net/Sockets/_MultipleConnectAsync.cs#L61

Dns.BeginGetHostAddresses doesn't complete async call and handle the exception from DnsCallback.

Are you observing NotImplementedException as the unhandled exception causing the crash or as first chance?

@alexsorokoletov
Copy link
Contributor Author

Does it fail the same way if you start the app w/o any available network connection? It seems Mono Socket will crash with NotImplementedException if connection attempt fails.

don't have a sample for that since we need to be online to start the app usually, from what I see it would be exactly same scenario

Are you observing NotImplementedException as the unhandled exception causing the crash or as first chance?

unhandled

@serkantkaraca
Copy link
Member

Opened a new issue in Mono repository to track this: mono/mono#6428

@migueldeicaza
Copy link

There is now a fix there, but we need this to get backported to test it.

@alexsorokoletov
Copy link
Contributor Author

Looks like TransportType=AmqpWebSockets has less crashes and handles socket errors better than Amqp.
Thank you Miguel for the changes, glad to see it in master.

@serkantkaraca
Copy link
Member

The issue is fixed in Mono

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants