Nginx 499 questions

Time:2021-7-28

scene

An interface exception is found in the project. When viewing the nginx log, it is 499 error, request_ Time is about 0.2S. Google later learned that the 499 error of nginx was caused by the user actively disconnecting, even if the interface was not very slow.

How to simulate 499

curl -m 0.01 "http://192.168.0.1/common/getDepart"
curl: (28) Operation timed out after 10 milliseconds with 0 bytes received

How to improve

When nginx receives a user’s active disconnection request, it directly disconnects the back-end reverse proxy by default. Although the user can’t improve, you can use nginx logs to record the real response process of the back-end (although the requesting user has been disconnected and nginx has also disconnected the back-end agent, the back-end still handles the task completely), such as upstream_ Status and upstream_ response_ Time (the default nginx is recorded -). How to record? Add the following on the server side of the nginx configuration file:

fastcgi_ ignore_ client_ abort on; // If the backend is fastcgi, such as PHP FPM

This work adoptsCC agreement, reprint must indicate the author and the link to this article