Review:
When you start the ocelot gateway, the following error is reported for the access interface:
Status Code: 502; Bad Gateway The project is ASP.NET Core 3.1,The version used by Ocelot is 16.0.1
info: Ocelot.RateLimit.Middleware.ClientRateLimitMiddleware[0] requestId: 0HM8JAOKL2C09:00000006, previousRequestId: no previous request id, message: EndpointRateLimiting is not enabled for /{url}
warn: Ocelot.Responder.Middleware.ResponderMiddleware[0] requestId: 0HM8JAOKL2C09:00000006, previousRequestId: no previous request id, message: Error Code: ConnectionToDownstreamServiceError Message: Error connecting to downstream service, exception: System.Net.Http.HttpRequestException: Request headers must contain only ASCII characters. at System.Net.Http.HttpConnection.WriteStringAsync(String s) at System.Net.Http.HttpConnection.WriteHeadersAsync(HttpHeaders headers, String cookiesFromContainer) at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) 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(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts) at Ocelot.Requester.HttpClientHttpRequester.GetResponse(HttpContext httpContext) errors found in ResponderMiddleware. Setting error response for request path:/test1/home/index, request method: GET Using Fiddler to catch packets as follows, I found that the cookie has a Chinese string, as follows:
Host: localhost:5002
Connection: keep-alive
Cache-Control: max-age=0
sec-ch-ua: "Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"
sec-ch-ua-mobile: ?0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cookie: aaa=测试
The browser writes a cookie code (The following code value is not escaped) can reproduce the issue:
Try to empty the cookie cache and the gateway returns to normal as shown in the image below:
The order of execution of the middleware with Ocelot is as follows:
PreErrorResponderMiddleware PreAuthenticationMiddleware AuthenticationMiddleware PreAuthorisationMiddleware AuthorisationMiddleware PreQueryStringBuilderMiddleware
(End)
|