Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Page: previous  1  2 
Avatar
jhunterspok #16
Member since Jul 2017 · 2 posts
Group memberships: Members
Show profile · Link to this post
In reply to post ID 10275
Hi, I'm also encountering a System.IO.IOException: Unable to write data to the transport connection: Cannot access a disposed object. error in my iOS application when I lock my device with the app running.  This error consistently occurs when the device is locked.

I am accessing the Matrix.Xamarin.iOS (version 2.1.0.0) project from within a PCL and I'm using latest stable version of  VS for Mac and Xamarin.iOS, so setting the TLS/SSL settings is not an option.

Please advise on how I may resolve this situation.

Thanks!


Here is the error information:

System.IO.IOException: Unable to write data to the transport connection: Cannot access a disposed object.
Socket.cs, line 2641

Object name: 'System.Net.Sockets.Socket'.. ---> System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.Socket'.
  at System.Net.Sockets.Socket.ThrowIfDisposedAndClosed () [0x00021] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/System/System.Net.Sockets/Socket.cs:2641
  at System.Net.Sockets.Socket.Send (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags, System.Net.Sockets.SocketError& errorCode) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/System/System.Net.Sockets/Socket.cs:1767
  at System.Net.Sockets.Socket.Send (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/System/net/System/Net/Sockets/Socket.cs:1536
  at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x0009b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/System/net/System/Net/Sockets/NetworkStream.cs:591
   --- End of inner exception stack trace ---
  at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x000c3] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/System/net/System/Net/Sockets/NetworkStream.cs:602
  at Mono.Net.Security.MobileAuthenticatedStream.InnerFlush () [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/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.10.0.36/src/mono/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:556
  at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (Mono.Net.Security.AsyncOperationStatus status) [0x00056] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/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.10.0.36/src/mono/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:218
  at Mono.Net.Security.AsyncProtocolRequest.StartOperation () [0x0003c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:204
  at Mono.Net.Security.AsyncProtocolRequest.StartOperation (Mono.Net.Security.AsyncOperation operation) [0x00024] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:189
  at Mono.Net.Security.MobileAuthenticatedStream.StartOperation (Mono.Net.Security.AsyncProtocolRequest& nestedRequest, Mono.Net.Security.BufferOffsetSize2& internalBuffer, Mono.Net.Security.AsyncOperation operation, Mono.Net.Security.AsyncProtocolRequest asyncRequest, System.String name) [0x0003c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:369
  at Mono.Net.Security.MobileAuthenticatedStream.Close () [0x00022] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:743
  at System.IO.Stream.Dispose () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/io/stream.cs:260
  at System.Net.Security.SslStream.Dispose (System.Boolean disposing) [0x0000d] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/System/System.Net.Security/SslStream.cs:345
  at System.IO.Stream.Close () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/io/stream.cs:248
  at System.IO.Stream.Dispose () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/io/stream.cs:260
  at Matrix.Net.ClientSocket.Disconnect () [0x00060] in <b75fb4cbb34f47f197cf71fbdec6d4c9>:0
  at Matrix.Net.ClientSocket.EndReceive (System.IAsyncResult ar) [0x00060] in <b75fb4cbb34f47f197cf71fbdec6d4c9>:0
  at System.Net.LazyAsyncResult.Complete (System.IntPtr userToken) [0x0003e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/System/net/System/Net/_LazyAsyncResult.cs:415
  at System.Net.LazyAsyncResult.ProtectedInvokeCallback (System.Object result, System.IntPtr userToken) [0x00064] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/System/net/System/Net/_LazyAsyncResult.cs:368
  at System.Net.LazyAsyncResult.InvokeCallback (System.Object result) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/System/net/System/Net/_LazyAsyncResult.cs:376
  at Mono.Net.Security.AsyncProtocolRequest.StartOperation () [0x0004b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:206
  at Mono.Net.Security.AsyncProtocolRequest.<StartOperation>b__17_0 (System.Object _) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:193
  at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x0000d] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1306
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:957
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:904
  at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00021] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1283
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/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/4691/d2270eec/source/xamarin-macios/src/ObjCRuntime/Runtime.cs:231
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00009] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1208
This post was edited on 2017-07-11, 11:21 by Alex.
Avatar
Kiril Tabakov #17
Member since Aug 2015 · 9 posts
Group memberships: Members
Show profile · Link to this post
Hey all, Alex we're experiencing the same issue on our iOS App, using Matrix for Xamarin iOS (the WinRT version works fine).

Here are the crash logs we managed to get from app harbor

Object name: 'System.Net.Sockets.Socket'.. ---> System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.Socket'.
System.Net.Sockets.Socket.ThrowIfDisposedAndClosed()Socket.cs:2641
System.Net.Sockets.Socket.Send(byte[] buffer, int offset, int size, SocketFlags socketFlags, ref SocketError errorCode)Socket.cs:1767
System.Net.Sockets.Socket.Send(byte[] buffer, int offset, int size, SocketFlags socketFlags)Socket.cs:1536
System.Net.Sockets.NetworkStream.Write(byte[] buffer, int offset, int size)NetworkStream.cs:591
--- End of inner exception stack trace ---
System.Net.Sockets.NetworkStream.Write(byte[] buffer, int offset, int size)NetworkStream.cs:602
Mono.Net.Security.MobileAuthenticatedStream.InnerFlush()MobileAuthenticatedStream.cs:562
Mono.Net.Security.MobileAuthenticatedStream.InnerWrite()MobileAuthenticatedStream.cs:556
Mono.Net.Security.AsyncProtocolRequest.ProcessOperation(AsyncOperationStatus status)AsyncProtocolRequest.cs:267
Mono.Net.Security.AsyncProtocolRequest.ProcessOperation()AsyncProtocolRequest.cs:218
Mono.Net.Security.AsyncProtocolRequest.StartOperation()AsyncProtocolRequest.cs:204
Mono.Net.Security.AsyncProtocolRequest.StartOperation(AsyncOperation operation)AsyncProtocolRequest.cs:189
Mono.Net.Security.MobileAuthenticatedStream.StartOperation(ref AsyncProtocolRequest nestedRequest, ref BufferOffsetSize2 internalBuffer, AsyncOperation operation, AsyncProtocolRequest asyncRequest, string name)MobileAuthenticatedStream.cs:369
Mono.Net.Security.MobileAuthenticatedStream.Close()MobileAuthenticatedStream.cs:743
System.IO.Stream.Dispose()stream.cs:260
System.Net.Security.SslStream.Dispose(bool disposing)SslStream.cs:345
System.IO.Stream.Close()stream.cs:248
System.IO.Stream.Dispose()stream.cs:260
Matrix.Net.ClientSocket.Disconnect()<b75fb4cbb34f47f197cf71fbdec6d4c9>:0
Matrix.Net.ClientSocket.EndReceive(IAsyncResult ar)<b75fb4cbb34f47f197cf71fbdec6d4c9>:0
System.Net.LazyAsyncResult.Complete(IntPtr userToken)_LazyAsyncResult.cs:415
System.Net.LazyAsyncResult.ProtectedInvokeCallback(object result, IntPtr userToken)_LazyAsyncResult.cs:368
System.Net.LazyAsyncResult.InvokeCallback(object result)_LazyAsyncResult.cs:376
Mono.Net.Security.AsyncProtocolRequest.StartOperation()AsyncProtocolRequest.cs:206
Mono.Net.Security.AsyncProtocolRequest.<StartOperation>b__17_0(object _)AsyncProtocolRequest.cs:193
System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state)threadpool.cs:1306
System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, object state, bool preserveSyncCtx)executioncontext.cs:957
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, object state, bool preserveSyncCtx)executioncontext.cs:904
System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()threadpool.cs:1283
System.Threading.ThreadPoolWorkQueue.Dispatch()threadpool.cs:856
ObjCRuntime.Runtime.ThreadPoolDispatcher(Func<TResult> callback)Runtime.cs:231
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()threadpool.cs:1208

Here is an error that happens more rarely

Mono.Net.Security.MobileAuthenticatedStream.StartOperation(ref AsyncProtocolRequest nestedRequest, ref BufferOffsetSize2 internalBuffer, AsyncOperation operation, AsyncProtocolRequest asyncRequest, string name)MobileAuthenticatedStream.cs:377
Mono.Net.Security.MobileAuthenticatedStream.Close()MobileAuthenticatedStream.cs:743
System.IO.Stream.Dispose()stream.cs:260
System.Net.Security.SslStream.Dispose(bool disposing)SslStream.cs:345
System.IO.Stream.Close()stream.cs:248
System.IO.Stream.Dispose()stream.cs:260
Matrix.Net.ClientSocket.Disconnect()<b75fb4cbb34f47f197cf71fbdec6d4c9>:0
Matrix.Net.ClientSocket.EndReceive(IAsyncResult ar)<b75fb4cbb34f47f197cf71fbdec6d4c9>:0
System.Net.LazyAsyncResult.Complete(IntPtr userToken)_LazyAsyncResult.cs:415
System.Net.LazyAsyncResult.ProtectedInvokeCallback(object result, IntPtr userToken)_LazyAsyncResult.cs:368
System.Net.LazyAsyncResult.InvokeCallback(object result)_LazyAsyncResult.cs:376
Mono.Net.Security.AsyncProtocolRequest.StartOperation()AsyncProtocolRequest.cs:206
Mono.Net.Security.AsyncProtocolRequest.<StartOperation>b__17_0(object _)AsyncProtocolRequest.cs:193
System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state)threadpool.cs:1306
System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, object state, bool preserveSyncCtx)executioncontext.cs:957
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, object state, bool preserveSyncCtx)executioncontext.cs:904
System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()threadpool.cs:1283
System.Threading.ThreadPoolWorkQueue.Dispatch()threadpool.cs:856
ObjCRuntime.Runtime.ThreadPoolDispatcher(Func<TResult> callback)Runtime.cs:231
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()threadpool.cs:1208

Please if it's possible add the same fix as for Mono or give us any advice how to proceed!

Thanks in advance!
Avatar
Alex #18
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
we have applied the patch mentioned here in this thread from the Mono version also to the Xamarin.iOS builds.
A new NuGet v 2.1.0.2 has been published.
Please let us know if this helps.
Avatar
jhunterspok #19
Member since Jul 2017 · 2 posts
Group memberships: Members
Show profile · Link to this post
Thank you for the very quick response!!!

Initial testing of the change looks good!  We're putting it through its paces now and I will reach out if we run into more difficulties with it.
Avatar
Kiril Tabakov #20
Member since Aug 2015 · 9 posts
Group memberships: Members
Show profile · Link to this post
Hey Alex,
Thanks for the quick response, it's working now.
Avatar
Alex #21
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
great to hear, thanks for the feedback.

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Page: previous  1  2