Error HTTPS Azure site

I've created an ApiWeb site hosted on Azure. I also access the APIs via APP xamarin.forms. If I set HTTP, everything works properly, if I enable the HTTPS domain, I can no longer query the APIs from xamarin.forms.
Where am I wrong?

In Xamarin.Forms I have, for HTTP
public Uri UriBaseAddress = new Uri ("http://myfirstapp20180927022910.azurewebsites.net/api/");

for HTTPS
public Uri UriBaseAddress = new Uri ("https://myfirstapp20180927022910.azurewebsites.net/api/");

Tagged:

Best Answer

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    Is there any error message ?

    Can you use Postman to see if you can fetch the data from server side first?

  • MarcoSalvatoriMarcoSalvatori USMember ✭✭✭

    postman is ok. HTTP or HTTPS works regularly.

    the code is:
    public static async Task GetAsyncResponse(string ApiString)
    {

                    VariabiliGlobali VarGlobal = VariabiliGlobali.Instance();
                    HttpClient _client = new HttpClient();
    
                    _client.BaseAddress = new Uri ("http://myfirstapp20180927022910.azurewebsites.net/api/");
                    _client.Timeout = TimeSpan.FromSeconds(60);
                    VarGlobal.BindingPage.Running = true;
    
                    try
                    {
                        HttpResponseMessage response = await _client.GetAsync(ApiString);
                        VarGlobal.BindingPage.Running = false;
                        return response;
                    }
                    catch (Exception ex) //when (ex is TaskCanceledException || ex is OperationCanceledException)
                    {
                        VarGlobal.BindingPage.Running = false;
                        return null;
                    }
                }
    

    the error is System.Threading.Tasks.TaskCanceledException

  • MarcoSalvatoriMarcoSalvatori USMember ✭✭✭

    New Update!!
    the System.Threading.Tasks.TaskCanceledException error i on Android emulator...

    on real device i have

    {System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error: SecureChannelFailure (The authentication or decryption has failed.) ---> System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: Error while sending TLS Alert (Fatal:InternalError): System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer. ---> etc etc

    now I know it's a permissions problem ...

  • ColeXColeX Member, Xamarin Team Xamurai

    Are you testing on ios or android ? and also on simulator or real device ?

  • MarcoSalvatoriMarcoSalvatori USMember ✭✭✭
    edited September 2018 Accepted Answer

    the initial error is misleading, I found it only in the android emulator.
    the real error, intercepted on a real device, is related to security parameters. error resolved by following what is reported in this thread:
    https://forums.xamarin.com/discussion/10405/the-authentication-or-decryption-has-failed-in-the-web-request

Sign In or Register to comment.