Netty on Android - IllegalSelectorException

Trustin Lee trustin at gleamynode.net
Mon Jan 19 11:57:37 EST 2009


BTW, it would be great if you could provide a simplistic sample
Android application project (Eclipse project) that reproduces the
problem, although it's just enough if you can modify
NioProviderMetadata.java to swallow all unexpected exceptions.  Please
let me know what the result looks like.

Thanks in advance,

— Trustin Lee, http://gleamynode.net/



On Tue, Jan 20, 2009 at 1:39 AM, Trustin Lee <trustin at gleamynode.net> wrote:
> This is a very interesting problem in that IllegalSelectorException is
> supposed to be raised when an attempt is made to register a channel
> with a selector that was not created by the provider that created the
> channel.  Apparently, it seems like you didn't try to change the NIO
> selector provider during the auto-detection process, right? (you
> shouldn't)  I suspect it's a bug of Android.
>
> Could you check out the latest revision of Netty from the SVN
> repository and modify the 301st line of NioProviderMetadata.java to
> catch java.lang.Exception instead of ClosedChannelException to see if
> it works around the problem?
>
> — Trustin Lee, http://gleamynode.net/
>
>
>
> On Sun, Jan 18, 2009 at 10:42 PM, Monk <funkmonk at gmx.net> wrote:
>>
>> Hi,
>> I try to port a Netty client to Android (using Netty 3.1.0 ALPHA3) and ran
>> into some trouble. Especially in this area of the code:
>>
>> private void initClientConnection() {
>>        String host = "10.0.2.2";
>>        int port = 8080;
>>
>>        this.factory =
>>            new NioClientSocketChannelFactory(
>>            Executors.newCachedThreadPool(),
>>            Executors.newCachedThreadPool());
>>
>>        this.bootstrap = new ClientBootstrap(factory);
>>
>>        this.handler = new ClientLogicHandler(this.main);
>>
>>        this.clPipelineFactory = new PipelineFactory(this.handler);
>>        bootstrap.setPipelineFactory(this.clPipelineFactory);
>>
>>        bootstrap.setOption("child.tcpNoDelay", true);
>>        bootstrap.setOption("child.keepAlive", true);
>>        bootstrap.setOption("remoteAddress", new InetSocketAddress(host,
>> port));
>>    }
>>
>> When simply running or debugging my program in the Android emulator (using
>> Eclipse), the following Exception appears:
>>
>> threadid=17: thread exiting with uncaught exception (group=0x40010e28)
>> Uncaught handler: thread Thread-10 exiting due to uncaught exception
>>  java.nio.channels.IllegalSelectorException
>>
>> java.nio.channels.spi.AbstractSelectableChannel.register(AbstractSelectableChannel.java:133)
>>  java.nio.channels.SelectableChannel.register(SelectableChannel.java:117)
>>
>> org.jboss.netty.channel.socket.nio.NioProviderMetadata$ConstraintLevelAutodetector
>>    .autodetectWithoutTimeout(NioProviderMetadata.java:300)
>>
>> org.jboss.netty.channel.socket.nio.NioProviderMetadata$ConstraintLevelAutodetector$1
>>    .run(NioProviderMetadata.java:242)
>>
>> org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:72)
>>  java.lang.Thread.run(Thread.java:935)
>>
>> I ran through it with the debugger and the exception seems to appear when
>> the first NioWorker gets created somewhere in the
>> NioClientSocketChannelFactory constructor which instantiates
>> NioClientSocketPipelineSink.
>>
>> Any suggestions what might be the problem? I would really appreciate your
>> help!
>>
>> --
>> View this message in context: http://n2.nabble.com/Netty-on-Android---IllegalSelectorException-tp2177020p2177020.html
>> Sent from the Netty User Group mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> netty-users mailing list
>> netty-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/netty-users
>>
>>
>




More information about the netty-users mailing list