-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Ocelot returns 500 from Consul for the first request #1294
Comments
hi chaitanyaphanikumar |
@chaitanyaphanikumar Hi Chaitanya Phani Kumar! Could you confirm, please, that @lufeiyuan83 advice helped to resolve the issue by changing provider type? |
…ements and fix errors (#1670) * fixing some issues in poll consul: - Timer is not thread safe, avoiding usage of it - No Ressources are returned for first call - Using a providers pool, instead of creating a new provider instance * line endings * adding some test cases * Using a lock instead of SemaphoreSlim * Improve code readability * CA2211: Non-constant fields should not be visible * Use IOcelotLogger to remove warnings & messages of static code analysis (aka IDE0052) * Fix errors with unit tests discovery. Remove legacy life hacks of discovering tests on .NET Core * Update unit tests * Also refactoring the kubernetes provider factory (like consul and eureka) * shorten references... * const before... * Some minor fixes, using Equals Ordinal ignore case and a string constant for provider type definition instead of string litterals. Fixing usings. * waiting a bit longer then? * @RaynaldM code review * renaming PollKubernetes to PollKube * ... odd... * ... very odd, we have an issue with configuration update duration... * IDE0002: Name can be simplified * All tests passing locally, hopefully it works online * just a bit of cleanup * Some missing braces and commas * Update servicediscovery.rst: Review and update "Consul" section --------- Co-authored-by: Guillaume Gnaegi <[email protected]> Co-authored-by: raman-m <[email protected]>
I have registered 3 services in Consul. (IdentityService is one of them). While trying to access this service through Ocelot, I had the below exception and Postman response returned 500 Internal server error.
Second request to this service returned 503 Service Unavailable.
Third request was Success and returned 200 OK.
Did I miss something to configure ?
Ocelot Configuration.json
{
"DownstreamPathTemplate": "/api/v1/identity/register",
"DownstreamScheme": "https",
"UseServiceDiscovery": true,
"ServiceName": "IdentityService",
"UpstreamPathTemplate": "/v1/identity/register",
"UpstreamHttpMethod": [ "POST" ],
"LoadBalancerOptions": {
"Type": "LeastConnection"
}
}
],
"GlobalConfiguration": {
"RequestIdKey": "OcRequestId",
"BaseUrl": "https://localhost:44311",
"ServiceDiscoveryProvider": {
"Scheme": "http",
"Host": "localhost",
"Port": 8500,
"Type": "Consul"
}
}
Exception (500 Reponse):-
Consul.ConsulRequestException: Unexpected response, status code ServiceUnavailable:
ERROR
The requested URL could not be retrieved
The following error was encountered while trying to retrieve the URL: http://localhost:8500/v1/health/service/IdentityService
Generated Mon, 20 Jul 2020 06:16:02 GMT by moatcmn-deb1 (squid/3.5.23)
at Consul.GetRequest`1.Execute(CancellationToken ct)
at Ocelot.Provider.Consul.Consul.Get()
at Ocelot.LoadBalancer.LoadBalancers.LoadBalancerFactory.<>c__DisplayClass2_0.<b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Ocelot.LoadBalancer.LoadBalancers.LeastConnection.Lease(DownstreamContext downstreamContext)
at Ocelot.LoadBalancer.Middleware.LoadBalancingMiddleware.Invoke(DownstreamContext context)
at Ocelot.QueryStrings.Middleware.ClaimsToQueryStringMiddleware.Invoke(DownstreamContext context)
at Ocelot.Headers.Middleware.ClaimsToHeadersMiddleware.Invoke(DownstreamContext context)
at Ocelot.Authorisation.Middleware.AuthorisationMiddleware.Invoke(DownstreamContext context)
at Ocelot.Claims.Middleware.ClaimsToClaimsMiddleware.Invoke(DownstreamContext context)
at Ocelot.Authentication.Middleware.AuthenticationMiddleware.Invoke(DownstreamContext context)
at Ocelot.RequestId.Middleware.ReRouteRequestIdMiddleware.Invoke(DownstreamContext context)
at Ocelot.RateLimit.Middleware.ClientRateLimitMiddleware.Invoke(DownstreamContext context)
at Ocelot.Request.Middleware.DownstreamRequestInitialiserMiddleware.Invoke(DownstreamContext context)
at Ocelot.Headers.Middleware.HttpHeadersTransformationMiddleware.Invoke(DownstreamContext context)
at Ocelot.Security.Middleware.SecurityMiddleware.Invoke(DownstreamContext context)
at Ocelot.Middleware.Multiplexer.Multiplexer.Fire(DownstreamContext context, OcelotRequestDelegate next)
at Ocelot.Middleware.Multiplexer.Multiplexer.Multiplex(DownstreamContext context, ReRoute reRoute, OcelotRequestDelegate next)
at Ocelot.DownstreamRouteFinder.Middleware.DownstreamRouteFinderMiddleware.Invoke(DownstreamContext context)
at Ocelot.Responder.Middleware.ResponderMiddleware.Invoke(DownstreamContext context)
at Ocelot.Middleware.Pipeline.MapWhenMiddleware.Invoke(DownstreamContext context)
at Ocelot.Errors.Middleware.ExceptionHandlerMiddleware.Invoke(DownstreamContext context)
2020-07-20 11:46:01.3982||DEBUG|Ocelot.Errors.Middleware.ExceptionHandlerMiddleware|requestId: 0HM1CCO82S6AR:00000001, previousRequestId: no previous request id, message: ocelot pipeline finished
Ocelot : 13.5.2
Net Core: 2.2
Any help is appreciated..
The text was updated successfully, but these errors were encountered: