|
Recap:
Ocelot Series (I) ASP.NET Core Gateway in Action h ttps:// www.itsvse.com/thread-9284-1-1.html
Starting the ocelot gateway and accessing the interface reports the following error: Status Code: 502; Bad Gateway & nbsp;   nbsp;   nbsp;   nbsp;   nbsp;   nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp nbsp;   nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp nbsp;   nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp nbsp;   nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp nbsp;   nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp; nbsp The project is ASP.NET Core 3.1 and Ocelot is using version 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. requestId: 0HM8JAOKL2C09:00000006, previousRequestId: no previous request id, message: Error Code. ConnectionToDownstreamServiceError Message: Error connecting to downstream service, exception: System.Net.Http. Request headers must contain only ASCII characters. HttpRequestException: Request headers must contain only ASCII characters. at System.Net.Http.HttpConnection.WriteStringAsync(String s) HttpConnection.WriteStringAsync(String s) at System.Net.Http.HttpConnection.WriteHeadersAsync(HttpHeaders headers, String CookiesFromContainer) at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken HttpConnection.SendAsyncore(HttpRequestMessage request, CancellationToken) at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, CancellationToken) HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken HttpRequestMessage request, CancellationToken) at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts) 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 Use Fiddler to capture the following packet, and found that the cookie has Chinese strings, 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=test
The problem is reproduced by the browser writing the cookie code ( value is not escaped in the code below ):
Browser console writes cookie h ttps:// www.itsvse.com/thread-4682-1-1.html Try to clear the cookie cache, the gateway is back to normal as shown below:
Attachment Ocelot executes the middleware in the following order:
PreErrorResponderMiddleware PreAuthenticationMiddleware AuthenticationMiddleware PreAuthorizationMiddleware AuthorizationMiddleware PreQueryStringBuilderMiddleware
(End) |
Previous: ASP.NET Core get request full URL linkNext article: Redis Benchmark benchmark performance test
|