79572911

Date: 2025-04-14 10:28:32
Score: 1
Natty:
Report link

Just posting the 2 solutions I found below:

  1. In the nginx.conf, add keepalive_timeout as 0s under the http context. This will close the connection on each request and the connections wont be pooled. Refer https://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_timeout. Its basically the number of seconds your connection will be kept alive once the response is sent back to the client

    1. Pros: Change only in one place. Configuration is not controlled by the client

    2. Cons: Not the recommended approach since it consumes resources as connections are not pooled.

  2. In the client request, send a header with key as 'Connection' and value as 'close'. This will also trigger the same behaviour as above

    1. Pros: Only one client will be requesting such configuration and other clients wont be affected and connection pooling can still be done for other clients

    2. Cons: Client has more control

Testing above changes

  1. Curl the requested endpoint with the -v flag since that will show you whether close_notify is being sent

    1. Result:

      1. enter image description here
Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Amol Kshirsagar