-
Notifications
You must be signed in to change notification settings - Fork 863
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
Random 502 errors when client cancels request #2070
Comments
What are you expecting instead? If you cancel a request, then the proxy isn't getting the information that it expects, so it returns an error. |
Actually without the proxy, the ui cancels the request and the user has no visual indication that the query was canceled. In chrome developer toolbar I only see the request as Canceled while with the proxy the call receives a 502 error code. Since from angular point of view the call is not canceled but the server returned an error it triggers our catch error routine that in turn shows to the user a "call failed message", resulting in a puzzled user because everything works as expeceted but he is seeing random "call errors". If I disable HTTP/2 on proxy configuration I was not able to recreate the error, so it seems a problem when the proxy uses HTTP/2 and the backend uses HTTP1.1 |
Another suggestion is: As you can see the error gets logged as INF
I really like this kind of message to be logged at least in WARN, am I wrong? |
How is it canceled, but not considered canceled? Can you share a runnable repro js script we could use that demonstrates that?
You're in luck, this was just recently changed to warning in main: #2044 |
I'll try to reproduce the error in the next days (tomorrow I have a conference and I'll be busy). Actually it does not happens all the time and seems to be related to cancellation before the client sent all the payload. The only thing I've noticed is that, if I disable HTTP/2 protocol on proxy the error never happens. |
Hello @MihaZupan Hello @alkampfergit We have encountered the same problem in our environment. The problem has been found with update to Yarp 2.0. But here with a Blazor Wasm client, SingalR and GRPC. The problem seems to occur only with Kestrel. In an IIS environment the problem seems to occur less often. Attached you can find a sample application consisting of a WASM client which opens a SignalR connection and then makes a GRPC call. Then the SignalR connection is closed and another GRPC call is made. This is done in a loop until the error occurs. With Yarp, the error occurs after about 120 runs:
Without Yarp the whole thing runs stable: What's interesting is that the client can't make any other calls to the server at all after the error. The error occurs then immediately. If you wait about 30 seconds, the system recovers and several calls are possible again. |
I can add that in our situation we have two different outcome after the first error,
|
Triage: Thanks for the repro @Schaeri! We're a bit busy, it might take a week or two before we get to it. |
Thanks @karelz for the feedback. I ran the example with the source code from Yarp (branch release/2.0). In a release build the behavior is the same. In the debug build the application terminates because of an assertion. Maybe the info helps. Here is the stack trace with the error:
|
I am getting similar error here ("Sent 0 request content bytes, but Content-Length promised 29."). I started getting that error after moving my code from the Program.cs to be inside a controller. So for now I will leave it outside of the controller. |
@Schaeri I was not able to reproduce locally the error with your sample. But @MihaZupan can so we are all good. |
@benjaminpetit: There are two applications in the ProblemDemo. The server, which contains all GRPC and SignalR endpoints and also delivers the client. The launchSettings.json defines the following URL for the application: https://localhost:7124. The application runs behind the gateway on the URL https://localhost:6001. See lanchSettins.json from the gateway. It is important that gateway and server are started and the application is called via the gateway (https://localhost:6001). Then I have the problem after maximal 200 runs. On Linux I tested with the browser Firefox and Chrome. On Windows only with Chrome. |
Sorry for not coming back sooner. If I do launch the demo with We should be able to do a workaround for this issue soon. Thanks again for the repro. |
Could you try this fix and see if it behaves like you expected? https://github.com/benjaminpetit/reverse-proxy/tree/fix/extended-connect I still see failures, but at least the connection isn't botched. |
@benjaminpetit Thanks for the help. Unfortunately I am not able to compile the code. We are using .Net 7.0 and I get the following build error:
HttpForwarder.cs
|
Sorry I merged it a bit fast, it should be ok now |
@benjaminpetit: Thank you very much. I was able to test the changes. It seems that our problem is solved. |
Random 502 errors when ui cancels the request.
We have an Angular UI application that talks to an ASP.NET webservice hosted in IIS and proxyed with YARP.
The backend only works with HTTP1.1 not HTTP/2
The error happens only if YARP uses HTTP/2, so the error happens only when YARP needs to proxy HTTP/2 traffic to a HTTP1.1 backend.
The application works as usual and we have some custom ui logic that cancels some of the requests, when the requests is cancelled YARP returns 502.
To Reproduce
I had not created a reproducible working scenario but I think that it is enough to issue a request then immediately cancels. From the browser I can see that the request has content-lenght of some bytes (49 in the above example) but the request was cancelled before the first byte of the content was transmitted so YARP complained.
Further technical details
The text was updated successfully, but these errors were encountered: