[
https://issues.apache.org/jira/browse/DIRMINA-1159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17482852#comment-17482852
]
Johan Oakes commented on DIRMINA-1159:
--------------------------------------
Hi [~elecharny], sorry if I misunderstand, but are you advising that we add
`proxyIoSession.setReconnectionNeeded(true) in `ProxyFilter.sessionClosed` like
so:
{code:java}
public void sessionClosed(NextFilter nextFilter, IoSession session) throws
Exception {
ProxyIoSession proxyIoSession = (ProxyIoSession)
session.getAttribute(ProxyIoSession.PROXY_SESSION);
proxyIoSession.setReconnectionNeeded(true);
proxyIoSession.getEventQueue().enqueueEventIfNecessary(
new IoSessionEvent(nextFilter, session, IoSessionEventType.CLOSED));
}
{code}
>From the output of my logs, that seems to be a solution since
>`ProxyFilter.sessionClosed()` is called when the peer disconnects. From there,
>we try to establish a new handler to do the handshake that'll eventually call
>`proxyIoSession.isReconnectionNeeded()`.
> 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
> Priority: Major
> 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]