[ 
https://issues.apache.org/jira/browse/DIRMINA-379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12592533#action_12592533
 ] 

Stefano Bagnara commented on DIRMINA-379:
-----------------------------------------

I tried adding isOpen and isConnected output to the exception by altering the 
SocketSessionImpl.setKeepAlive (mina 1.1.8-SNAPSHOT) this way:
        public void setKeepAlive(boolean on) {
                        boolean isConnected = ch.isConnected();
                        boolean isOpen = ch.isOpen();
            try {
                        ch.socket().setKeepAlive(on);
            } catch (SocketException e) {
                throw new RuntimeIOException("setKeepAlive error isOpen: 
"+isOpen+"/"+ch.isOpen()+" isConnected: "+isConnected+"/"+ch.isConnected(), e);
            }
        }

The result is this exception:

1513 [AnonymousIoService-8] WARN 
org.apache.mina.common.support.DefaultExceptionMonitor - Unexpected exception.
org.apache.mina.common.RuntimeIOException: setKeepAlive error isOpen: true/true 
isConnected: true/true
        at 
org.apache.mina.transport.socket.nio.SocketSessionImpl$SessionConfigImpl.setKeepAlive(SocketSessionImpl.java:238)
        at 
org.apache.mina.transport.socket.nio.SocketSessionImpl.<init>(SocketSessionImpl.java:101)
        at 
org.apache.mina.transport.socket.nio.SocketConnector.newSession(SocketConnector.java:341)
        at 
org.apache.mina.transport.socket.nio.SocketConnector.processSessions(SocketConnector.java:295)
        at 
org.apache.mina.transport.socket.nio.SocketConnector.access$800(SocketConnector.java:53)
        at 
org.apache.mina.transport.socket.nio.SocketConnector$Worker.run(SocketConnector.java:383)
        at 
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.net.SocketException: Invalid argument: 
sun.nio.ch.Net.setIntOption
        at sun.nio.ch.Net.setIntOption0(Native Method)
        at sun.nio.ch.Net.setIntOption(Net.java:154)
        at sun.nio.ch.SocketChannelImpl$1.setInt(SocketChannelImpl.java:406)
        at sun.nio.ch.SocketOptsImpl.setBoolean(SocketOptsImpl.java:38)
        at sun.nio.ch.SocketOptsImpl.keepAlive(SocketOptsImpl.java:92)
        at sun.nio.ch.SocketOptsImpl$IP$TCP.keepAlive(SocketOptsImpl.java:268)
        at sun.nio.ch.OptionAdaptor.setKeepAlive(OptionAdaptor.java:139)
        at sun.nio.ch.SocketAdaptor.setKeepAlive(SocketAdaptor.java:322)
        at 
org.apache.mina.transport.socket.nio.SocketSessionImpl$SessionConfigImpl.setKeepAlive(SocketSessionImpl.java:236)
        ... 7 more

So the channel is OPEN and CONNECTED.

Furthermore I logged the exception from the MINA test failure:

Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.043 sec
Running org.apache.mina.transport.socket.nio.SocketBindTest
9357 [SocketAcceptor-8] WARN 
org.apache.mina.common.support.DefaultExceptionMonitor - Unexpected exception.
org.apache.mina.common.RuntimeIOException: setKeepAlive error isOpen: true/true
isConnected: true/true
        at 
org.apache.mina.transport.socket.nio.SocketSessionImpl$SessionConfigImpl.setKeepAlive(SocketSessionImpl.java:238)
        at 
org.apache.mina.transport.socket.nio.SocketSessionImpl.<init>(SocketSessionImpl.java:101)
        at 
org.apache.mina.transport.socket.nio.SocketAcceptor$Worker.processSessions(SocketAcceptor.java:283)
        at 
org.apache.mina.transport.socket.nio.SocketAcceptor$Worker.run(SocketAcceptor.java:225)
        at 
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.net.SocketException: Invalid argument: 
sun.nio.ch.Net.setIntOption
        at sun.nio.ch.Net.setIntOption0(Native Method)
        at sun.nio.ch.Net.setIntOption(Net.java:154)
        at sun.nio.ch.SocketChannelImpl$1.setInt(SocketChannelImpl.java:406)
        at sun.nio.ch.SocketOptsImpl.setBoolean(SocketOptsImpl.java:38)
        at sun.nio.ch.SocketOptsImpl.keepAlive(SocketOptsImpl.java:92)
        at sun.nio.ch.SocketOptsImpl$IP$TCP.keepAlive(SocketOptsImpl.java:268)
        at sun.nio.ch.OptionAdaptor.setKeepAlive(OptionAdaptor.java:139)
        at sun.nio.ch.SocketAdaptor.setKeepAlive(SocketAdaptor.java:322)
        at 
org.apache.mina.transport.socket.nio.SocketSessionImpl$SessionConfigImpl.setKeepAlive(SocketSessionImpl.java:236)
        ... 5 more
Tests run: 5, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 7.677 sec <<< 
FAILURE!

Tests in error:
  
testUnbindDisconnectsClients(org.apache.mina.transport.socket.nio.SocketBindTest)

The fact that also the mina test also fails from time to time let me hope that 
this is not an issue in my code!

I also tried to alter the order of the setkeepAlive/setReuseAddress as 
suggested by Daniel Wirtz in the previous comment but it didn't fix the issue 
in my app: I still get the same very exception on the setKeepAlive. The only 
difference is that I get the exception few seconds later.

Unfortunately I'm not able to create a small test that always fail. The good 
news (or bad??) is that my application fails 100% of the runs.

I'm not sure I understand Alan message: is he saying that we have to report 
this to bugs.sun.com and that we cannot do anything to fix this in MINA? Isn't 
any workaround we can use to temporarily solve this issue?


> setKeepAlive/setTcpNoDelay and exceptions in Windows Vista
> ----------------------------------------------------------
>
>                 Key: DIRMINA-379
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-379
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.0.3, 1.1.0, 2.0.0-M1
>         Environment: Windows Vista Home Premium Italian
> Java SE 1.5.0_11, Java SE 1.6 Update 1, Java SE 1.4.2_12
>            Reporter: Stefano Bagnara
>
> When I ran my application under Vista I get this exception:
> Exception in thread "Thread-4" org.apache.mina.common.RuntimeIOException: 
> java.net.SocketException: Invalid argument: sun.nio.ch.Net.setIntOption
>       at 
> org.apache.mina.transport.socket.nio.SocketSessionImpl$SessionConfigImpl.setKeepAlive(SocketSessionImpl.java:252)
>       at 
> org.apache.mina.transport.socket.nio.SocketSessionImpl.<init>(SocketSessionImpl.java:94)
>       at 
> org.apache.mina.transport.socket.nio.SocketConnector.newSession(SocketConnector.java:350)
>       at 
> org.apache.mina.transport.socket.nio.SocketConnector.processSessions(SocketConnector.java:290)
>       at 
> org.apache.mina.transport.socket.nio.SocketConnector.access$900(SocketConnector.java:53)
>       at 
> org.apache.mina.transport.socket.nio.SocketConnector$Worker.run(SocketConnector.java:395)
>       at 
> org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:43)
>       at java.lang.Thread.run(Thread.java:595)
> Caused by: java.net.SocketException: Invalid argument: 
> sun.nio.ch.Net.setIntOption
>       at sun.nio.ch.Net.setIntOption0(Native Method)
>       at sun.nio.ch.Net.setIntOption(Net.java:152)
>       at sun.nio.ch.SocketChannelImpl$1.setInt(SocketChannelImpl.java:372)
>       at sun.nio.ch.SocketOptsImpl.setBoolean(SocketOptsImpl.java:38)
>       at sun.nio.ch.SocketOptsImpl.keepAlive(SocketOptsImpl.java:92)
>       at sun.nio.ch.OptionAdaptor.setKeepAlive(OptionAdaptor.java:139)
>       at sun.nio.ch.SocketAdaptor.setKeepAlive(SocketAdaptor.java:322)
>       at 
> org.apache.mina.transport.socket.nio.SocketSessionImpl$SessionConfigImpl.setKeepAlive(SocketSessionImpl.java:248)
>       ... 7 more
> I had to remove the following lines from the SocketSessionImpl constructor:
> this.config.setKeepAlive( cfg.isKeepAlive() );
> this.config.setTcpNoDelay( cfg.isTcpNoDelay() );
> and now it works.
> No matter if I change the configuration to let them return true or false, I 
> keep getting the exception if I don't remove the call at all.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to