ThreeMammals / Ocelot

.NET API Gateway

Home Page:https://www.nuget.org/packages/Ocelot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UnableToFindDownstreamRouteError, Failed to match Route configuration for upstream path: /, verb: GET

pseudorasbora opened this issue · comments

hi:

upgrade from 22.0.1 to 23.0.0:

it throws error "bad gateway, 502" when using method "get". methods "put/post/delete" work well.

ocelot log:
requestId: 0HM5DM6ULMR8I:00000002, previousRequestId: no previous request id, message: Error Code: UnableToFindDownstreamRouteError Message: Failed to match Route configuration for upstream path: /api/xxx, verb: GET. errors found in ResponderMiddleware. Setting error response for request path:/api/xxx, request method: GET

now it works after rollback to 22.0.1.

thanks!

Hi

Could you attach ocelot.json file and C# app startup code (configuring services etc.) please?
Also full exception call stack is desired.

But it is better to upload full app code for review.

So, please provide more information!

@pseudorasbora
Is it so difficult to attach more details here?
We cannot decide having so short description!

@AlyHKafoury Are you online?

sorry, it's online.

ocelot.json

{
  "Routes": [

    {
      "DownstreamPathTemplate": "/{url}",
      "DownstreamScheme": "https",
      "UpstreamPathTemplate": "/msgapi/{url}",
      "UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ],
      "ServiceName": "MsgApi",
      "LoadBalancerOptions": {
        "Type": "NoLoadBalancer"
      },

      "RateLimitOptions": {
        "EnableRateLimiting": true,
        "Period": "1s", 
        "PeriodTimespan": 3, 
        "Limit": 5
      },

      "QoSOptions": {
        "ExceptionsAllowedBeforeBreaking": 3, 
        "DurationOfBreak": 60000, 
        "TimeoutValue": 120000 
      },

      "AuthenticationOptions": {
        "AuthenticationProviderKey": "gatewayBearer",
        "AllowedScopes": []
      },

      "DangerousAcceptAnyServerCertificateValidator": true
    }

  ],
  "GlobalConfiguration": {
    "BaseUrl": "https://gtw.dev.com",

    //consul
    "ServiceDiscoveryProvider": {
      "Scheme": "http",
      "Host": "localhost",
      "Port": 3123,
      "Type": "Consul", 
      "Token": "xxxxxxxxxxxxxxxxxxxxx", 
      "ConfigurationKey": "ocelot" 
    },

    "RateLimitOptions": {
      "DisableRateLimitHeaders": false,
      "QuotaExceededMessage": "xxxx",
      "HttpStatusCode": 222,
      "ClientIdHeader": "client-id" 
    }

  }
}

startup code

            services
                .AddOcelot(new ConfigurationBuilder()
                    .AddJsonFile("ocelot.json", optional: false, reloadOnChange: true)
                    .Build())
                .AddPolly()   
                .AddConsul();

logs

2024-02-25 13:57:36.917 +08:00 [WRN] requestId: 0HN1LOOV1BJ61:00000021, previousRequestId: No PreviousRequestId, message: '502 (Bad Gateway) status code, request uri: https://msgapi.dev.com:44322/messages/5705287553122309'
2024-02-25 13:58:02.718 +08:00 [WRN] requestId: 0HN1LOOV1BJ61:00000022, previousRequestId: No PreviousRequestId, message: 'DownstreamRouteFinderMiddleware setting pipeline errors. IDownstreamRouteFinder returned Error Code: UnableToFindDownstreamRouteError Message: Failed to match Route configuration for upstream path: /, verb: GET.'
2024-02-25 13:58:02.719 +08:00 [WRN] requestId: 0HN1LOOV1BJ61:00000022, previousRequestId: No PreviousRequestId, message: 'Error Code: UnableToFindDownstreamRouteError Message: Failed to match Route configuration for upstream path: /, verb: GET. errors found in ResponderMiddleware. Setting error response for request path:/, request method: GET'
2024-02-25 13:58:07.979 +08:00 [WRN] requestId: 0HN1LOOV1BJ61:00000025, previousRequestId: No PreviousRequestId, message: '502 (Bad Gateway) status code, request uri: https://msgapi.dev.com:44322/messages/5705287553122309'
2024-02-25 14:04:51.023 +08:00 [WRN] requestId: 0HN1LOUM7UL5G:00000001, previousRequestId: No PreviousRequestId, message: 'You have ignored all SSL warnings by using DangerousAcceptAnyServerCertificateValidator for this DownstreamRoute, UpstreamPathTemplate: Ocelot.Values.UpstreamPathTemplate, DownstreamPathTemplate: /{url}'

2024-02-25 14:07:06.661 +08:00 [WRN] requestId: 0HN1LOUM7UL5H:00000002, previousRequestId: No PreviousRequestId, message: '502 (Bad Gateway) status code, request uri: https://msgapi.dev.com:44322/agents/10001'
2024-02-25 14:07:19.338 +08:00 [WRN] requestId: 0HN1LOUM7UL5G:00000012, previousRequestId: No PreviousRequestId, message: 'Error Code: RequestTimedOutError Message: Timeout making http request, exception: Polly.CircuitBreaker.BrokenCircuitException`1[System.Net.Http.HttpResponseMessage]: The circuit is now open and is not allowing calls.
   at Polly.CircuitBreaker.CircuitStateController`1.OnActionPreExecute()
   at Polly.CircuitBreaker.AsyncCircuitBreakerEngine.ImplementationAsync[TResult](Func`3 action, Context context, CancellationToken cancellationToken, Boolean continueOnCapturedContext, ExceptionPredicates shouldHandleExceptionPredicates, ResultPredicates`1 shouldHandleResultPredicates, ICircuitController`1 breakerController)
   at Polly.AsyncPolicy`1.ExecuteAsync(Func`3 action, Context context, CancellationToken cancellationToken, Boolean continueOnCapturedContext)
   at Polly.AsyncPolicy`1.ExecuteAsync(Func`3 action, Context context, CancellationToken cancellationToken, Boolean continueOnCapturedContext)
   at Ocelot.Provider.Polly.PollyPoliciesDelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at Ocelot.Requester.TimeoutDelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpMessageInvoker.<SendAsync>g__SendAsyncWithTelemetry|6_0(HttpMessageHandler handler, HttpRequestMessage request, CancellationToken cancellationToken)
   at Ocelot.Requester.MessageInvokerHttpRequester.GetResponse(HttpContext httpContext) errors found in ResponderMiddleware. Setting error response for request path:/agents/10001, request method: GET'

@ggnaegi Please consult this developer! 🙏 I expect misconfiguration issue...
I'm a bit tired of such inquiries...

hi:

upgrade from 22.0.1 to 23.0.0:

it throws error "bad gateway, 502" when using method "get". methods "put/post/delete" work well.

ocelot log:
requestId: 0HM5DM6ULMR8I:00000002, previousRequestId: no previous request id, message: Error Code: UnableToFindDownstreamRouteError Message: Failed to match Route configuration for upstream path: /api/xxx, verb: GET. errors found in ResponderMiddleware. Setting error response for request path:/api/xxx, request method: GET

now it works after rollback to 22.0.1.

thanks!

Hello @pseudorasbora a lot of new features and changes were introduced in the release 23. We are going to release 23.1 next week. Could you try the new release first (a bug with the request content has been addressed)? If the issue persist, we will try to find a solution with you.

⚠️ Could you maybe change Ocelot log level and provide us more verbose logs?

Thanks!

release 23.1

hi,
it worked well after upgrading to release 23.1 .
thanks for ur help!

@ggnaegi Please consult this developer! 🙏 I expect misconfiguration issue... I'm a bit tired of such inquiries...

thanks for ur help!