Ocelot: Sometimes Health Check is Very Slow, or Throw Exception

Created on 2 Nov 2018  路  2Comments  路  Source: ThreeMammals/Ocelot

Halo!
Before reroute request to real service, Ocelot will request Consul's Health Check Api. Sometimes it is very slow, or throw exception like below.
When I can't recieve response, I request the realy health check url(http://localhost:8500/v1/health/service/WebApiServer?passing=1
), and it is work. I guess there is something wrong with the Health Check in Ocelot(ver 11.0.3, ver 12.0.1).

2018-11-01 12:59:25,163 [47] INFO Com.XX.WebApi.ServiceGateway.Startup Request starting HTTP/1.1 POST http://MyIP:MyPort/WebApiServer/Robot/Receive application/json;charset=UTF-8 746
2018-11-01 12:59:25,164 [47] INFO Com.XX.WebApi.ServiceGateway.Startup 璇锋眰:http://MyIP:MyPort/WebApiServer/Robot/Receive
2018-11-01 12:59:25,164 [47] INFO Com.XX.WebApi.ServiceGateway.Startup requestId: 0HLHVLGEHVMN7:00000001, previousRequestId: no previous request id, message: EndpointRateLimiting is not enabled for /api/{url}
2018-11-01 12:59:25,165 [47] INFO Com.XX.WebApi.ServiceGateway.Startup requestId: 0HLHVLGEHVMN7:00000001, previousRequestId: no previous request id, message: No authentication needed for /WebApiServer/Robot/Receive
2018-11-01 12:59:25,165 [47] INFO Com.XX.WebApi.ServiceGateway.Startup requestId: 0HLHVLGEHVMN7:00000001, previousRequestId: no previous request id, message: /api/{url} route does not require user to be authorised
2018-11-01 13:01:13,113 [55] INFO Com.XX.WebApi.ServiceGateway.Startup Request finished in 107945.1118ms 200 application/json; charset=utf-8
2018-11-01 13:01:13,128 [52] INFO Com.XX.WebApi.ServiceGateway.Startup requestId: 0HLHVLGEHVMN6:00000001, previousRequestId: no previous request id, message: Error making http request, exception: System.Threading.Tasks.TaskCanceledException: A task was canceled.
at System.Threading.Tasks.ValueTask1.get_Result() at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Ocelot.Requester.HttpClientHttpRequester.GetResponse(DownstreamContext context)
2018-11-01 13:01:13,130 [52] INFO Com.XX.WebApi.ServiceGateway.Startup requestId: 0HLHVLGEHVMN6:00000001, previousRequestId: no previous request id, message: Error Code: UnableToCompleteRequestError Message: Error making http request, exception: System.Threading.Tasks.TaskCanceledException: A task was canceled.
at System.Threading.Tasks.ValueTask1.get_Result() at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Ocelot.Requester.HttpClientHttpRequester.GetResponse(DownstreamContext context) errors found in ResponderMiddleware. Setting error response for request path:/WebApiServer/Robot/Receive, request method: POST
2018-11-01 13:01:13,133 [52] INFO Com.XX.WebApi.ServiceGateway.Startup Request finished in 174762.1142ms 0

bug help wanted

Most helpful comment

I have encountered this problem too,see https://bbs.rupeng.com/Post/Index/4100
I would try to solve it after I start to work in the team.

All 2 comments

I've solved it.
image

{
"ReRoutes": [
{
"DownstreamPathTemplate": "/api/{url}",
"DownstreamScheme": "http",
"UpstreamPathTemplate": "/WebApiServer/{url}",
"UpstreamHttpMethod": [ "Get", "Post" ],
"ServiceName": "WebApiServer",
"UseServiceDiscovery": true,
"HttpHandlerOptions": {
"UseTracing": false,
"UseProxy": false
},
"Timeout": 20
}
]
}

I have encountered this problem too,see https://bbs.rupeng.com/Post/Index/4100
I would try to solve it after I start to work in the team.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LuketaD2 picture LuketaD2  路  3Comments

mkanakis picture mkanakis  路  3Comments

mjrousos picture mjrousos  路  6Comments

dmitriifilonenko picture dmitriifilonenko  路  5Comments

secret-agent-B picture secret-agent-B  路  4Comments