The Early Closed Connection (HTTP status code 499 in NGINX) occurs when a client terminates the connection before the server has had the chance to send a response. This is a client-side initiated action and falls under the 4xx class of status codes, which typically represent client errors. However, it is a normal part of web activity and doesn't necessarily indicate a problem.
499s are generally not problematic and should be treated as business as usual unless there's a sharp increase, which would warrant an investigation into possible client network connection reliability.
In an ideal scenario, a client sends a request and the server processes it, returning a response - usually with a status code 200 (OK) for successful requests. However, if the client cancels the request before the server has finished processing it, it is logged as 499 (NGINX custom code). This cancellation can occur for several reasons:
- Client Timeout: The client has a set timeout for how long it is willing to wait for a response. If the server takes longer, the client aborts the request.
- User Cancels a Request: If the user manually cancels the request - such as by closing the browser tab/window, clicking the Refresh, Back, or Cancel button - the connection is terminated, leading to a 499.
Why is a 499 not an error?
Though the 499 status code falls within the 4xx range (client errors), it is not necessarily an issue. It’s simply a normal part of web traffic. Aborted requests happen for various reasons, and many of them are part of routine operations, especially in environments where users frequently change actions or drop connectivity.
Early Closed Connection in PubNub
In PubNub, modifying the list of subscribed channels - by adding or removing them - cancels the existing HTTP subscribe request and initiates a new one with the updated list. This behaviour is expected and is the primary reason for 499 status codes, as the client closes the original request to establish a new one.
Nevertheless, a sudden increase in 499 codes can signal a potential problem when it comes to requests made to PubNub network:
- Too short client timeout settings may cause requests to be aborted before the server can respond. If you explicitly set any PubNub timeouts lower than the defaults, consider increasing them or consult support for best practices.
- Unstable client network: Intermittent Wi-Fi, low mobile data signal, or client-side network issues can cause clients to drop requests mid-transaction.
In case of any questions, contact us at support@pubnub.com.