ooeunz opened a new pull request, #508:
URL: https://github.com/apache/httpcomponents-core/pull/508

   ## Description
   
   - Introduced a configuration option useRstOnTimeout in Http1Config to allow 
connections to be closed with an RST (Reset) signal when a timeout occurs.
   - Updated HttpRequestExecutor to respect this configuration and invoke the 
appropriate close mode (CloseMode.IMMEDIATE for RST or Closer.closeQuietly for 
FIN).
   - Maintained backward compatibility by defaulting to FIN-based connection 
closure.
   
   This change improves flexibility and allows faster resource cleanup in 
timeout scenarios, aligning with the HTTP/1.1 recommendations for abnormal 
connection termination.
   
   ## Problem Description
   
   There is an issue where the connection close operation takes as long as the 
SocketTimeout value set in the SocketConfig after a Socket timeout occurs. This 
behavior arises because the NioSocketImpl performs an additional poll for the 
duration of the SocketTimeout during the close operation. Consequently, HTTP 
requests may experience delays of up to twice the configured SocketTimeout 
value.
   
   
   ## Proposed Solution
   
   This Pull Request introduces the useRstOnTimeout configuration option to 
mitigate this issue by enabling connections to be closed using an RST signal 
instead of a FIN-based closure.
   - Key benefits:
     - Avoids unnecessary delays during connection closure.
     - Ensures efficient resource cleanup.
     - Maintains backward compatibility by defaulting to FIN-based closure.
   
   _The following image shows the test results with the socket timeout value 
set to 5 seconds_
   <img width="1466" alt="img-1" 
src="https://github.com/user-attachments/assets/9176273c-a89c-49be-a117-29104ce2384f";>
   
   <img width="1022" alt="img-2" 
src="https://github.com/user-attachments/assets/0cc6eda5-d0a3-49b5-9f6b-8df956cc711c";>
   
   
   ## Example Workflow Before Fix
   
   1. Socket timeout occurs:
      The socket reaches the timeout value specified in the SocketTimeout 
configuration.
   2. Connection close:
      During the close operation, the NioSocketImpl performs an additional poll 
for the same timeout duration.
   3. Total wait time:
      HTTP requests may end up waiting for up to twice the configured 
SocketTimeout value.
   
   Resolves: HTTPCLIENT-2324


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to