Johan Oakes created DIRMINA-1159:
------------------------------------

             Summary: HTTP Proxy Reconnect with SSL
                 Key: DIRMINA-1159
                 URL: https://issues.apache.org/jira/browse/DIRMINA-1159
             Project: MINA
          Issue Type: Bug
          Components: Core, Filter, Handler, Protocol - HTTP
    Affects Versions: 2.1.5
            Reporter: Johan Oakes
         Attachments: clean_http_reconnect.log

Related to: [https://www.quickfixj.org/jira/browse/QFJ-997]

 

In short, HTTP(S) reconnection is not possible with a Proxy in the event the 
peer server shuts down.

The check for reconnection at {*}/org/apache/mina/proxy/ProxyConnector{*}:
{code:java}
// If proxy does not use reconnection like socks the connector's // future is 
returned. If we're in the middle of a reconnection // then we send back the 
connector's future which is only used // internally while <code>future</code> 
will be used to notify // the user of the connection state.
if (proxyIoSession.getRequest() instanceof SocksProxyRequest || 
proxyIoSession.isReconnectionNeeded()) {
    return conFuture;
}
 {code}
When a peer shuts down, the *SslHandler* receives a message to close the 
connection, and eventually destroy it (
{code:java}
        // Close inbound and flush all remaining data if available.
        try {
            sslEngine.closeInbound();
        } catch (SSLException e) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Unexpected exception from 
SSLEngine.closeInbound().", e);
            }
        }
{code}
In the logs, you'll see the "Unexpected exception from 
SSLEngine.closeInbound()" message. The *proxyIoSession.isReconnectionNeeded()* 
will never be set to true once this happens.

 

In *AbstractHttpLogicHandler.handleResponse()),* this logic also defaults to 
false.
{code:java}
if (!isHandshakeComplete() && 
("close".equalsIgnoreCase(StringUtilities.getSingleValuedHeader(response.getHeaders(),
 "Proxy-Connection")) || 
    
"close".equalsIgnoreCase(StringUtilities.getSingleValuedHeader(response.getHeaders(),
 "Connection")))) {
    getProxyIoSession().setReconnectionNeeded(true);
}
{code}
 

If we change proxy type to SOCKS(4/5) we are seeing the reconnect attempt due 
to {*}/org/apache/mina/proxy/ProxyConnector.java:181{*}, but would be nice to 
have the same functionality for the HTTP proxy. For HTTP sessions, 
*proxyIoSession.isReconnectionNeeded()* defaults to false since it's never set 
in the event of Handler exception.

I also can't see any obvious way to set the *ProxyIoSession.reconnectionNeeded* 
variable that would potentially trigger the reconnection.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to