reverse-proxy
reverse-proxy copied to clipboard
Why does Yarp return 502 status code when a client disconnects?
502 (Bad Gateway) is usually returned when the reverse proxy encounters an error while trying to forward the request to the backend server, but in the case where a client disconnects should it not set the status code to 499?
By "return", are you just referring to the values you see in logs? By definition, the client won't see the value.
Yes, that's correct, the client won't see the value, I meant in logs and observability tools like new relic.
499 is a non-standard code that NGinx made up. It being a defacto standard might be sufficient cause to use it though.
In general, you should look at the ForwarderError for a more detailed explanation. https://github.com/microsoft/reverse-proxy/blob/79a7b806688311fd2cca2ca67dc7cc418c7925ab/src/ReverseProxy/Forwarder/ForwarderError.cs#L39
We're starting to use 499 in AspNetCore for this situation as well: https://github.com/dotnet/aspnetcore/pull/46330
If that goes through then we should do something similar here. We'll even be able to use the new constant on .NET 8.