Aurélien Pupier created CAMEL-27890:
---------------------------------------

             Summary: camel-netty-http - 401 response to a request without 
valid basic auth credentials closes the channel without telling the client
                 Key: CAMEL-27890
                 URL: https://issues.apache.org/jira/browse/CAMEL-27890
             Project: Camel
          Issue Type: Bug
          Components: camel-netty-http
            Reporter: Aurélien Pupier
            Assignee: Aurélien Pupier


When the netty-http consumer rejects a request because the basic authentication 
credentials are missing or invalid, it writes the 401 response and closes the 
channel, but the response has no {{Connection: close}} header, and the channel 
is closed without waiting for the write to complete.

As a consequence, a netty-http producer (or any HTTP/1.1 client) sees a 
keep-alive response and keeps the connection for reuse. The next request on the 
same connection randomly fails because the server has closed it, with an error 
like {{CamelExchangeException: No response received from remote server}} or 
{{StacklessClosedChannelException}}. The close may also race with the write of 
the 401 response itself.

This was found through the flaky test NettyHttpSharedSecurityConfigurationTest 
(CAMEL-27880): a request answered with 401 followed by an authenticated request 
fails now and then (about 3 times in 500 iterations in a loop reproducer).

Fix: set {{Connection: close}} on the 401 response and close the channel once 
the response is written.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to