RabbitMQ-dotnet-client System.ObjectDisposedException: Cannot access a disposed object

1,097 views
Skip to first unread message

Dirk Wilhelm

unread,
Apr 17, 2018, 3:08:00 AM4/17/18
to rabbitmq-users
Hello,

i'm using the rabbitmq-dotnet-client (5.0.1) in a Xamarin.Forms mobile app. This is so far running very well on iOS, but on android i sometimes get the following exception:

Xamarin caused by: android.runtime.JavaProxyThrowable: System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> System.ObjectDisposedException: Cannot access a disposed object.
Object name: '
System.Net.Sockets.Socket'.
  at System.Net.Sockets.Socket.ThrowIfDisposedAndClosed () [0x0001b] in <df383ead7ec84cd9bb35d79a4f1bb5da>:0
  at System.Net.Sockets.Socket.EndConnect (System.IAsyncResult asyncResult) [0x00000] in <df383ead7ec84cd9bb35d79a4f1bb5da>:0
  at System.Net.Sockets.SocketTaskExtensions+<>c.<ConnectAsync>b__3_1 (System.IAsyncResult asyncResult) [0x00006] in <df383ead7ec84cd9bb35d79a4f1bb5da>:0
  at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x00019] in <71b7f02e3f7b451d9ca3f5b56c70ecd8>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <71b7f02e3f7b451d9ca3f5b56c70ecd8>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <71b7f02e3f7b451d9ca3f5b56c70ecd8>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <71b7f02e3f7b451d9ca3f5b56c70ecd8>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <71b7f02e3f7b451d9ca3f5b56c70ecd8>:0
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <71b7f02e3f7b451d9ca3f5b56c70ecd8>:0
  at RabbitMQ.Client.TcpClientAdapter+<ConnectAsync>d__2.MoveNext () [0x0011b] in <6c6c3e3a3313428a95760fcdae28a7c0>:0
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.ObjectDisposedException: Cannot access a disposed object.
Object name: '
System.Net.Sockets.Socket'.
  at System.Net.Sockets.Socket.ThrowIfDisposedAndClosed () [0x0001b] in <df383ead7ec84cd9bb35d79a4f1bb5da>:0
  at System.Net.Sockets.Socket.EndConnect (System.IAsyncResult asyncResult) [0x00000] in <df383ead7ec84cd9bb35d79a4f1bb5da>:0
  at System.Net.Sockets.SocketTaskExtensions+<>c.<ConnectAsync>b__3_1 (System.IAsyncResult asyncResult) [0x00006] in <df383ead7ec84cd9bb35d79a4f1bb5da>:0
  at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x00019] in <71b7f02e3f7b451d9ca3f5b56c70ecd8>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <71b7f02e3f7b451d9ca3f5b56c70ecd8>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <71b7f02e3f7b451d9ca3f5b56c70ecd8>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <71b7f02e3f7b451d9ca3f5b56c70ecd8>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <71b7f02e3f7b451d9ca3f5b56c70ecd8>:0
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <71b7f02e3f7b451d9ca3f5b56c70ecd8>:0
  at RabbitMQ.Client.TcpClientAdapter+<ConnectAsync>d__2.MoveNext () [0x0011b] in <6c6c3e3a3313428a95760fcdae28a7c0>:0 <---

I'm not sure on how to fix this in my app, so i'm looking for help here.

Regards,
  Dirk



Michael Klishin

unread,
Apr 17, 2018, 10:48:51 AM4/17/18
to rabbitm...@googlegroups.com
We have no experience with the .NET client on Android.

The exception seems to state that at the time the socket was closed,
the socket object somehow was already disposed. It sounds like an exception that can be ignored for all intents and purposes.

I am personally quite wary of runtime-specific issues and changes but we would consider a PR that handles such cases in the client itself.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ
Reply all
Reply to author
Forward
0 new messages