You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Kishore Mokkarala <ki...@gmail.com> on 2023/04/10 10:47:40 UTC

Migration from apache mina 2.0.21 to 2.0.23

Hi,
There was a security vulnerability in mina 2.0.21,So we were migrated
from apache mina 2.0.21 to 2.0.23,locally in the dev environment everything
looks good, but in production we are facing connection timeout issue with
the mina version 2.0.23.
For connection set up it was taking 10-20 milliseconds (less than a second)
with the old version (2.0.21).
With the new version even after 40 seconds connection was timed out.

We use the same NioSocketConnector  instance for opening 100
parallel connections.

*Question:*
My question is why it is taking more time more than 40 seconds for opening
the socket with the new version ?
We are not using https communication.
Could you please suggest a work around.
What's happening in the below code is mina is time out in 40 seconds and
also IO session is connected using state machine,both are running in two
parallel threads,This issue is not seen with the mina 2.0.21 version.

*Here is the code snippet.*

 private static final ExecutorFilter executorFilter = new
ExecutorFilter(16,32);

    StateMachine stateMachine =
StateMachineFactory.getInstance(IoHandlerTransition.class).create(
                G10MinaClient.CONNECTED, new G10MinaClient(processor));

        IoHandler ioHandler = new
StateMachineProxyBuilder().setStateContextLookup(
                new IoSessionStateContextLookup(new StateContextFactory() {
                    @Override
                    public StateContext create() {
                        final G10StateContext stateContext = new
G10StateContext();
                        stateContext.setStartedTime(new Date());
                        return stateContext;
                    }
                })).create(IoHandler.class, stateMachine);

NioSocketConnector connector = new NioSocketConnector();
        connector.getFilterChain().addLast("LoggingFilter",
G10CaptureService.loggingFilter);
        connector.getFilterChain().addLast("codecFilter",
G10CaptureService.probeCodecFilter);
        connector.getFilterChain().addLast("executorFilter",
G10CaptureService.executorFilter);
        connector.getFilterChain().addLast("gpbMessageFilter",
G10CaptureService.gpbMessageFilter);
        connector.getFilterChain().addLast("keepAliveFilter",
G10CaptureService.keepAliveFilter);
        connector.setHandler(ioHandler);
ConnectFuture primaryConnectFuture = connector.connect(primaryAddress,
initializer);
if (!primaryConnectFuture.awaitUninterruptibly(MINA_CLOSE_TIMEOUT))
//MINA_CLOSE_TIMEOUT is 40 seconds
{

                    if (handleIOException(searchExpression,
captureHandler)) {
                        return;
                    }
                    LOG.info("{} Apache mina connection setup time out
happend.",
                    handleConnectionFailed(primaryAddress, captureHandler,
"Primary IP connection timeout");
                    return;
}

Regards,
M.V.S.Kishore
91-9886412814