Connection success on Android falsely reported when no network is present

Trustin Lee trustin at gmail.com
Mon Jan 3 22:22:55 EST 2011


Hi,

This is a known issue of the Android platform.  I'd strobgly recommend using OIO rather than NIO for less platform specific issues and better battery utilization.

--
Trustin Lee - http://gleamynode.net/
Sent from a mobile device - please excuse the brevity.

On Dec 21, 2010, at 10:35 PM, Karlis Zigurs <homolupus at gmail.com> wrote:

> Hello,
> 
> I've encountered an interesting behaviour using netty (3.2.3-final) on
> android (2.2) - if there is no data connection available on device
> (out of coverage or packet data disabled) bootstrap.connect() future
> succeeds, but channel fails immediately with the following exception
> (if the connectivity is marginal failure cases work ok):
> 
>        java.net.SocketException: Transport endpoint is not connected
>        at org.apache.harmony.luni.platform.OSNetworkSystem.readSocketDirectImpl(Native
> Method)
>        at org.apache.harmony.luni.platform.OSNetworkSystem.readDirect(OSNetworkSystem.java:384)
>        at org.apache.harmony.nio.internal.SocketChannelImpl.readImpl(SocketChannelImpl.java:459)
>        at org.apache.harmony.nio.internal.SocketChannelImpl.read(SocketChannelImpl.java:382)
>        at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:322)
>        at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:281)
>        at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:201)
>        at org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
>        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
>        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
>        at java.lang.Thread.run(Thread.java:1096)
> 
> Connection itself is set up as follows:
> 
> --- in thread one
> bootstrap.setOption("child.keepAlive", false);
> bootstrap.setOption("child.tcpNoDelay", true);
> bootstrap.setOption("child.connectTimeoutMillis", 15000);
> 
> bootstrap.setOption("remoteAddress", new
> InetSocketAddress("10.10.10.10(servers' ip address)", 1234(port no)));
> bootstrap.setPipelineFactory(new CustomPipeline(...));
> 
> --- in thread two, (after boostrap is initiated)
> ChannelFuture future = bootstrap.connect();
> future.awaitUninterruptibly();
> 
> if (future.isSuccess()) {
>    Channel futureChannel = future.getChannel();
>    //Operations on channel
> } ...
> ===
> 
> I've tried checking for success using channels' (if present)
> isConnected(), but that claims it's connected as well.
> This does look like Android/Harmony bug, but if anybody has
> encountered something similar, suggestions would be welcome.
> 
> Br,
> Karlis Zigurs
> _______________________________________________
> netty-dev mailing list
> netty-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-dev



More information about the netty-dev mailing list