Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting load balancer error with latest version #2063

Closed
vikasgupta1456 opened this issue May 10, 2024 · 6 comments
Closed

Getting load balancer error with latest version #2063

vikasgupta1456 opened this issue May 10, 2024 · 6 comments
Labels
Load Balancer Ocelot feature: Load Balancer needs validation Issue has not been replicated or verified yet Service Discovery Ocelot feature: Service Discovery wontfix No plan to include this issue in the Ocelot core functionality.

Comments

@vikasgupta1456
Copy link

vikasgupta1456 commented May 10, 2024

I am trying to upgrade to latest version of ocelot (23.2.2). But when I am hitting one of my endpoint, I get an error. This works until 23.1.0. which means '23.2.0' also has the same issue. Can you let me know what changed ?

I have routing like this:

{ 
"Routes": [ {
 "ServiceName": "myapp",
"LoadBalancerOptions": { 
  "Type": "LeastConnection"
  },
"UpstreamPathTemplate": "/document/read/{catchAll}",
"DownstreamPathTemplate": "/{catchAll}",
"DownstreamScheme": "https",
"Priority": 1
} ] }

And getting this error :

Error Code: UnableToFindLoadBalancerError
Message: Unable to find load balancer for \u0027/document/read/{catchAll}|no-host|no-host-and-port|no-svc-ns|myapp|LeastConnection|no-lb-key\u0027.
Exception: System.NullReferenceException: Object reference not set to an instance of an object.
  at Ocelot.ServiceDiscovery.ServiceDiscoveryProviderFactory.GetServiceDiscoveryProvider(ServiceProviderConfiguration config, DownstreamRoute route)
  at Ocelot.ServiceDiscovery.ServiceDiscoveryProviderFactory.Get(ServiceProviderConfiguration serviceConfig, DownstreamRoute route)
  at Ocelot.LoadBalancer.LoadBalancers.LoadBalancerFactory.Get(DownstreamRoute route, ServiceProviderConfiguration config)
  at Ocelot.LoadBalancer.LoadBalancers.LoadBalancerHouse.GetResponse(DownstreamRoute route, ServiceProviderConfiguration config)
  at Ocelot.LoadBalancer.LoadBalancers.LoadBalancerHouse.Get(DownstreamRoute route, ServiceProviderConfiguration config);
errors found in ResponderMiddleware. Setting error response for request path:/document/read/12345, request method: GET\u0027"
@ggnaegi
Copy link
Member

ggnaegi commented May 10, 2024

Thanks @vikasgupta1456 for your feedback, let us check that and come back to you.

@ggnaegi ggnaegi added needs validation Issue has not been replicated or verified yet Load Balancer Ocelot feature: Load Balancer labels May 10, 2024
@raman-m
Copy link
Member

raman-m commented May 10, 2024

@vikasgupta1456
Could you please share the entire JSON content of your ocelot.json file? It would be helpful to see the GlobalConfiguration section as well. However, it's best to copy and paste the entire file content here.


An error in the method at Ocelot.LoadBalancer.LoadBalancers.LoadBalancerHouse.Get(DownstreamRoute route, ServiceProviderConfiguration config); suggests there may be an issue with the ServiceProviderConfiguration config argument. It's possible that the ServiceProviderConfiguration.Type is not recognized. Additionally, the definition of "ServiceName": "myapp" within the route indicates that the application setup utilizes service discovery.

  • Have you consulted the Service Discovery documentation?
  • Which service discovery provider are you employing: Consul, Kubernetes, Eureka, a custom one?

@raman-m raman-m added Service Discovery Ocelot feature: Service Discovery waiting Waiting for answer to question or feedback from issue raiser labels May 10, 2024
@raman-m
Copy link
Member

raman-m commented May 10, 2024

@vikasgupta1456

I am trying to upgrade to latest version of ocelot (23.2.2). But when I am hitting one of my endpoint, I get an error. This works until 23.1.0. which means '23.2.0' also has the same issue. Can you let me know what changed ?

The response and potential solutions depend on the type of service discovery provided.
In the Hornussen release, v23.1.0, the Load Balancer was updated 👇

However, it seems your issue may be related to a Global Configuration problem. It's worth considering if PR #1944 might have introduced a bug.

@vikasgupta1456
Copy link
Author

vikasgupta1456 commented May 13, 2024

This is my ocelot.json file

{
  "Routes": [
    { 
  "ChangeDownstreamPathTemplate": {},
  "DelegatingHandlers": [],
  "DownstreamHeaderTransform": {},
  "DownstreamHostAndPorts": [],
  "DownstreamHttpMethod": null,
  "DownstreamHttpVersion": null,
  "DownstreamPathTemplate": "/{catchAll}",
  "DownstreamScheme": "https",
  "FileCacheOptions": {
    "TtlSeconds": 0,
    "Region": "",
    "Header": null
  },
  "HttpHandlerOptions": {
    "AllowAutoRedirect": false,
    "MaxConnectionsPerServer": 2127483647,
    "UseCookieContainer": false,
    "UseProxy": true,
    "UseTracing": false,
    "PooledConnectionLifetimeSeconds": null
  },
  "Key": null,
  "LoadBalancerOptions": {
    "Expiry": 2127483647,
    "Key": "",
    "Type": "LeastConnection"
  },
  "Priority": 1,
  "QoSOptions": {
    "DurationOfBreak": 1,
    "ExceptionsAllowedBeforeBreaking": 0,
    "TimeoutValue": 0
  },
  "RateLimitOptions": {
    "ClientWhitelist": [],
    "EnableRateLimiting": false,
    "Period": null,
    "PeriodTimespan": 0.0,
    "Limit": 0
  },
  "RequestIdKey": null,
  "RouteClaimsRequirement": {},
  "RouteIsCaseSensitive": false,
  "SecurityOptions": {
    "IPAllowedList": [],
    "IPBlockedList": [],
    "ExcludeAllowedFromBlocked": false
  },
  "ServiceName": "myapp",
  "ServiceNamespace": null,
  "Timeout": 0,
  "UpstreamHeaderTransform": {},
  "UpstreamHost": null,
  "UpstreamHttpMethod": [],
  "UpstreamPathTemplate": "/document/read/{catchAll}"
}
],
"GlobalConfiguration": {
  "RequestIdKey": null,
  "ServiceDiscoveryProvider": {
    "Scheme": null,
    "Host": null,
    "Port": 0,
    "Type": null,
    "Token": null,
    "ConfigurationKey": null,
    "PollingInterval": 0,
    "Namespace": null
  },
  "RateLimitOptions": {
    "ClientIdHeader": "ClientId",
    "QuotaExceededMessage": null,
    "RateLimitCounterPrefix": "ocelot",
    "DisableRateLimitHeaders": false,
    "HttpStatusCode": 429
  },
  "QoSOptions": {
    "DurationOfBreak": 1,
    "ExceptionsAllowedBeforeBreaking": 0,
    "TimeoutValue": 0
  },
  "BaseUrl": null,
  "LoadBalancerOptions": {
    "Expiry": 2127483647,
    "Key": "",
    "Type": ""
  },
  "DownstreamScheme": null,
  "HttpHandlerOptions": {
    "AllowAutoRedirect": false,
    "MaxConnectionsPerServer": 2127483647,
    "UseCookieContainer": false,
    "UseProxy": true,
    "UseTracing": false,
    "PooledConnectionLifetimeSeconds": null
  },
  "DownstreamHttpVersion": null
}

@raman-m
Copy link
Member

raman-m commented May 13, 2024

@vikasgupta1456
Did you read my recommendations above?

@raman-m
Copy link
Member

raman-m commented May 13, 2024

{
  "Routes": [
    { 
  "DownstreamPathTemplate": "/{catchAll}",
  "DownstreamScheme": "https",
  "Key": null,
  "LoadBalancerOptions": {
    "Type": "LeastConnection"
  },
  "ServiceName": "myapp", // This property requires to setup service discovery options in GlobalConfiguration
  "ServiceNamespace": null,
  "UpstreamPathTemplate": "/document/read/{catchAll}"
}
],
"GlobalConfiguration": {
  "ServiceDiscoveryProvider": {
    "Scheme": null,
    "Host": null,
    "Port": 0,
    "Type": null, // Developer must provide the type of service discovery provider: Consul, Kube, Eureka etc.!
    "Token": null,
    "ConfigurationKey": null,
    "PollingInterval": 0,
    "Namespace": null
  },
}

Read Service Discovery docs!
Good luck in development!

@raman-m raman-m closed this as not planned Won't fix, can't repro, duplicate, stale May 13, 2024
@raman-m raman-m added wontfix No plan to include this issue in the Ocelot core functionality. and removed waiting Waiting for answer to question or feedback from issue raiser labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Load Balancer Ocelot feature: Load Balancer needs validation Issue has not been replicated or verified yet Service Discovery Ocelot feature: Service Discovery wontfix No plan to include this issue in the Ocelot core functionality.
Projects
None yet
Development

No branches or pull requests

3 participants