Ocelot: The handshake failed due to an unexpected packet format

Created on 4 Jun 2019  路  1Comment  路  Source: ThreeMammals/Ocelot

Expected Behavior / New Feature

When I change the DownstreamSchemeconfig to https as in follows the routing must be accomplished

{
      "DownstreamPathTemplate": "/api/{version}/{everything}",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "www.myhost.com",
          "Port": 80
        }
      ],
      "UpstreamPathTemplate": "/{version}/a/{everything}",
        "UpstreamHttpMethod": [ "Get", "Post" ]
    }

Actual Behavior / Motivation for New Feature

I get an error

warn: Ocelot.Responder.Middleware.ResponderMiddleware[0]
      requestId: 0HLN8VGHGQRVC:00000001, previousRequestId: no previous request id, message: Error Code: UnableToCompleteRequestError Message: Error making http request, exception: System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.IO.IOException: The handshake failed due to an unexpected packet format.
         at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
         at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
      --- End of stack trace from previous location where exception was thrown ---
         at System.Net.Security.SslState.ThrowIfExceptional()
         at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
         at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
         at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
         at System.Net.Security.SslStream.<>c.<AuthenticateAsClientAsync>b__47_1(IAsyncResult iar)
         at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
      --- End of stack trace from previous location where exception was thrown ---
         at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
         --- End of inner exception stack trace ---
         at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
         at System.Threading.Tasks.ValueTask`1.get_Result()
         at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
         at System.Threading.Tasks.ValueTask`1.get_Result()
         at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
         at System.Threading.Tasks.ValueTask`1.get_Result()
         at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
         at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
         at Ocelot.Requester.HttpClientHttpRequester.GetResponse(DownstreamContext context) errors found in ResponderMiddleware. Setting error response for request path:/v1/a/user/Sign-In, request method: POST

Steps to Reproduce the Problem

changing http to https in DownstreamScheme config

Specifications

  • Platform: .net core 2.1

Most helpful comment

I found the problem
When we use HTTPS, we need to change the port to 443!

{
      "DownstreamPathTemplate": "/api/{version}/{everything}",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "www.myhost.com",
          "Port": 443
        }
      ],
      "UpstreamPathTemplate": "/{version}/a/{everything}",
        "UpstreamHttpMethod": []
}

>All comments

I found the problem
When we use HTTPS, we need to change the port to 443!

{
      "DownstreamPathTemplate": "/api/{version}/{everything}",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "www.myhost.com",
          "Port": 443
        }
      ],
      "UpstreamPathTemplate": "/{version}/a/{everything}",
        "UpstreamHttpMethod": []
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dmitriifilonenko picture dmitriifilonenko  路  5Comments

jefferson picture jefferson  路  3Comments

piyey picture piyey  路  6Comments

ioritzalberdi picture ioritzalberdi  路  5Comments

mkanakis picture mkanakis  路  3Comments