SSL connection error in Xamarin.Forms while calling FHIRClient

Mahesh Balasubramanian 1 Reputation point
2022-02-06T14:42:06.04+00:00

Hi,

I am using Firely hl7 sdk for a mobile app in xamarin.forms. I am getting the follwoing error while calling the FHIRClient. Same code in .net Console application works. Please help me resolve this issue.

Error Line:

var client = new FhirClient("https://server.fire.ly/r4/");
patientread = client.Read<Patient>($"Patient/{pat.Id}");

Error Message:
System.Net.Http.HttpRequestException
Message=The SSL connection could not be established, see inner exception.
Source=Hl7.Fhir.Support.Poco
StackTrace:
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore (System.IO.Stream stream, System.Net.Security.SslClientAuthenticationOptions sslOptions, System.Threading.CancellationToken cancellationToken) [0x000f6] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs:176
at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.CreateConnectionAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x002d8] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:408 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync (System.Threading.Tasks.ValueTask1[TResult] creationTask) [0x000a2] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:543 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync (System.Net.Http.HttpRequestMessage request, System.Boolean doRequestAuth, System.Threading.CancellationToken cancellationToken) [0x0003f] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:284
at System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00070] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RedirectHandler.cs:32
at System.Net.Http.DecompressionHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00080] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/DecompressionHandler.cs:48
at System.Net.Http.HttpClient.FinishSendAsyncBuffered (System.Threading.Tasks.Task1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) [0x0017e] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:506 at Hl7.Fhir.Rest.HttpClientRequester.ExecuteAsync (Hl7.Fhir.Rest.EntryRequest interaction) [0x001b6] in <31499258d6ee4ba5b9c2016903e74307>:0 at Hl7.Fhir.Rest.TaskExtensions.WaitResult[T] (System.Threading.Tasks.Task1[TResult] task) [0x00020] in <31499258d6ee4ba5b9c2016903e74307>:0
at Hl7.Fhir.Rest.BaseFhirClient.Read[TResource] (System.String location, System.String ifNoneMatch, System.Nullable`1[T] ifModifiedSince) [0x00009] in <92e64a20fe7c4506810226d155c77f0f>:0
at MES_FHIR_App.DashboardPage.ReadJsonProcessing () [0x0004c] in C:\Users\mahebalasubramani\source\repos\MES_FHIR_App\MES_FHIR_App\MES_FHIR_App\DashboardPage.xaml.cs:135
at MES_FHIR_App.DashboardPage..ctor (System.Boolean observationFlag, System.Boolean profileFlag) [0x00033] in C:\Users\mahebalasubramani\source\repos\MES_FHIR_App\MES_FHIR_App\MES_FHIR_App\DashboardPage.xaml.cs:33
at MES_FHIR_App.AuthorizationPage.Button_Clicked (System.Object sender, System.EventArgs e) [0x00005] in C:\Users\mahebalasubramani\source\repos\MES_FHIR_App\MES_FHIR_App\MES_FHIR_App\AuthorizationPage.xaml.cs:26
at Xamarin.Forms.Button.Xamarin.Forms.Internals.IButtonElement.PropagateUpClicked () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Button.cs:187
at Xamarin.Forms.ButtonElement.ElementClicked (Xamarin.Forms.VisualElement visualElement, Xamarin.Forms.Internals.IButtonElement ButtonElementManager) [0x0001f] in D:\a\1\s\Xamarin.Forms.Core\ButtonElement.cs:61
at Xamarin.Forms.Button.SendClicked () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Button.cs:173
at Xamarin.Forms.Platform.Android.ButtonElementManager.OnClick (Xamarin.Forms.VisualElement element, Xamarin.Forms.IButtonController buttonController, Android.Views.View v) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\ButtonElementManager.cs:25
at Xamarin.Forms.Platform.Android.FastRenderers.ButtonRenderer.Android.Views.View.IOnClickListener.OnClick (Android.Views.View v) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\FastRenderers\ButtonRenderer.cs:72
at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v) [0x00010] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-30/mcw/Android.Views.View.cs:2255
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.65(intptr,intptr,intptr)

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,284 questions
{count} votes