Refit 6, net 5 error Cannot determine the frame size or a corrupted frame was received

0

I found the following similar SO answer that didn't fix my issue.

I have a 5.0 console app and the HttpClient is being configured manually instead of using the Refit extension factory method (both ways result in the error).

Console app config, previous attempt to use refit factory extension method. I believe the answer is here somewhere...I need to find a way to define the the Ssl protocol here.

  var builder = 
    new HostBuilder()
        //.ConfigureServices((hostContext, services) =>
        //{
        //  services.AddRefitClient<IIdentityApi>()
        //          .ConfigureHttpClient(c => c.BaseAddress = new Uri("https://localhost:20595"));
       //})
      .UseConsoleLifetime();

Here is that code:

  var httpClientHandler = new HttpClientHandler
  {
     // tried Tls11, Tls13, None
     SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13
  };

 var httpClient = new HttpClient(httpClientHandler)
 {
    BaseAddress = new Uri("https://localhost:20595")
 };

 var identityApi = RestService.For<IIdentityApi>(httpClient);

Stacktrace:

  System.Net.Http.HttpRequestException
  HResult=0x80131620
  Message=The SSL connection could not be established, see inner exception.
  Source=System.Net.Http
  StackTrace:
  ...
  Inner Exception 1:
  IOException: Cannot determine the frame size or a corrupted frame was received.
c#
httpclient
refit
asked on Stack Overflow May 11, 2021 by Will Lopez

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0