Hello,
I am working on XamarinAndroid application which uses TCP Connection and SSLStream to communicate with server. It has been working perfectly fine till now until recently when I tried with larger data.
The data approx 3-4KB (I know 3-4KB is nothing) and we don't get any server response now. No error, nothing. If we move the same code to a C# console app under .NET 4/0/4.5, it works perfectly fine. If the data we receive is less than 3KB, it works fine.
This is the line where the execution hangs - StreamReader streamreader = new StreamReader(sslStream); ....... messageReceivedFromServer = streamreader.ReadLine(); // The execution hangs here
I even tried to pause the execution to check the callstack it seems its waiting on EndRead. Here is the callstack...
System.Threading.WaitHandle.WaitOne_internal () in System.Threading.WaitHandle.WaitOne () in Mono.Security.Protocol.Tls.SslStreamBase.EndRead (asyncResult={Mono.Security.Protocol.Tls.SslStreamBase.InternalAsyncResult}) in System.Net.Security.SslStream.EndRead (asyncResult={Mono.Security.Protocol.Tls.SslStreamBase.InternalAsyncResult}) in System.Net.Security.SslStream.Read (buffer={byte[1024]}, offset=0, count=1024) in System.IO.StreamReader.ReadBuffer () in System.IO.StreamReader.ReadLine () in Downloading.MainActivity.b__0 (param0=The vm is not suspended., param1={System.EventArgs}) in d:\Downloading\Downloading\Downloading\MainActivity.cs:58 Android.Views.View.IOnClickListenerImplementor.OnClick (v=The vm is not suspended.) in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.10.2-branch/4b53fbd0/source/monodroid/src/Mono.Android/platforms/android-17/src/generated/Android.Views.View.cs:1824 Android.Views.View.IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (jnienv=0x40d597e0, native__this=0xffffffffe6e00019, native_v=0xffffffffa110001d) in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.10.2-branch/4b53fbd0/source/monodroid/src/Mono.Android/platforms/android-17/src/generated/Android.Views.View.cs:1791 object.41ae2452-d17c-441e-8853-59c5c760cb4f (arg0=0x40d597e0, arg1=0xffffffffe6e00019, arg2=0xffffffffa110001d) in
And android log....... [Mono] The request to load the assembly System v2.0.5.0 was remapped to v2.0.0.0 [Mono] Assembly System[0x56dceaa8] added to domain RootDomain, ref_count=1 [linker] load_library(linker.cpp:757): library "System.dll.so" not found [linker] load_library(linker.cpp:757): library "/data/data/Downloading.Downloading/lib/System.dll.so" not found [Mono] AOT failed to load AOT module System.dll.so: Cannot load library: load_library(linker.cpp:757): library "/data/data/Downloading.Downloading/lib/System.dll.so" not found [Mono] The request to load the assembly mscorlib v2.0.5.0 was remapped to v2.0.0.0 [Mono] Unloading image mscorlib.dll [0x56dda180]. [Mono] The request to load the assembly Mono.Security v2.0.5.0 was remapped to v2.0.0.0 [Mono] Assembly Mono.Security[0x56de1960] added to domain RootDomain, ref_count=1 [linker] load_library(linker.cpp:757): library "Mono.Security.dll.so" not found [linker] load_library(linker.cpp:757): library "/data/data/Downloading.Downloading/lib/Mono.Security.dll.so" not found [Mono] AOT failed to load AOT module Mono.Security.dll.so: Cannot load library: load_library(linker.cpp:757): library "/data/data/Downloading.Downloading/lib/Mono.Security.dll.so" not found [Mono] The request to load the assembly mscorlib v2.0.5.0 was remapped to v2.0.0.0 [Mono] Unloading image mscorlib.dll [0x56de6a98]. Loaded assembly: System.dll [External] Loaded assembly: Mono.Security.dll [External] [libc-netbsd] getaddrinfo: server.awesomeshare.com get result from proxy >> [Mono] DllImport attempting to load: '/system/lib/liblog.so'. [Mono] DllImport loaded library '/system/lib/liblog.so'. [Mono] DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so'). [Mono] Searching for '__android_log_print'. [Mono] Probing '__android_log_print'. [Mono] Found as '__android_log_print'. [Mono] The request to load the assembly System v2.0.5.0 was remapped to v2.0.0.0 [Mono] Unloading image System.dll [0x573fb4c8]. [Mono] The request to load the assembly System v2.0.5.0 was remapped to v2.0.0.0 [Mono] Unloading image System.dll [0x56e2c158]. Thread started: #2 Thread started: #3 Thread started: #4 Thread started: #5 Thread started: #6 [Mono] The request to load the assembly System.Core v2.0.5.0 was remapped to v3.5.0.0 [Mono] Unloading image System.Core.dll [0x57a7c538]. [Mono] The request to load the assembly System.Core v2.0.5.0 was remapped to v3.5.0.0 [Mono] Unloading image System.Core.dll [0x57ab37a8]. Attached is the code file for your reference.
To me, it seems to an SSLStream Issue/Bug but not sure how do I validate. Any idea how do I fix/workaround this issue? I am really stuck on this issue.
Thank you, Rupreet