mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Attila Kelemen (JIRA)" <j...@apache.org>
Subject [jira] [Created] (DIRMINA-993) Connecting to server occasionally fails when using TCP_NODELAY
Date Mon, 03 Nov 2014 15:29:33 GMT
Attila Kelemen created DIRMINA-993:

             Summary: Connecting to server occasionally fails when using TCP_NODELAY
                 Key: DIRMINA-993
                 URL: https://issues.apache.org/jira/browse/DIRMINA-993
             Project: MINA
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.0.9
         Environment: Windows (tested on Vista and 7)
            Reporter: Attila Kelemen

Mina sometimes fails to connect to a remote TCP server when TCP_NODELAY is set for a `NioSocketConnector`.

    NioSocketConnector connector = new NioSocketConnector();
    try {
        connector.setHandler(new IoHandlerAdapter());
        ConnectFuture future = connector.connect(new InetSocketAddress("localhost", myport));
    } finally {

The above code sometimes (rarely) fails with an exception (thrown by getSession()) with a
(wrapped) "java.net.SocketException: Invalid argument: no further information" exception.
The best way to reproduce the problem is to run the above code concurrently multiple times
(e.g. as done by this method: https://github.com/kelemen/JTrim/blob/v1.7.3/jtrim-core/src/main/java/org/jtrim/concurrent/Tasks.java#L173).

I have also found a simplified JDK only code which reproduces the issue (more reliably) where
the order of JDK calls are in the same order as Mina does:

    SocketChannel channel = SocketChannel.open();
    try {
        channel = SocketChannel.open();
        channel.connect(new InetSocketAddress("localhost", myport));

    } finally {

In the above code if `setTcpNoDelay` had been called before `connect` there is no exception
thrown. Also worth noting, that it seems, that if `setTcpNoDelay(true)` is called again after
a failure, the call seems to eventually succeed (possibly after many retries).

This message was sent by Atlassian JIRA

View raw message