My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 9431: [Android 2.2] Java NIO Selector open fails on devices without IPv6 support (SocketException)
20 people starred this issue and may be notified of changes. Back to list
Status:  Released
Owner:  e...@google.com
Closed:  Aug 2010
Cc:  b...@google.com, e...@google.com

Restricted
  • Only users with Commit permission may comment.


Sign in to add a comment
 
Reported by rednos...@gmail.com, Jun 30, 2010
I developed an application using java NIO, it works fine on Android 2.1.
But the application doesn't work on Android 2.2(Froyo).
The problem is NIO Selector open fail.
Here is logs...
---------
 java.net.SocketException: Bad address family
     at org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocketImpl(Native Method)
     at org.apache.harmony.luni.platform.OSNetworkSystem.connect(OSNetworkSystem.java:115)
     at org.apache.harmony.nio.internal.SocketChannelImpl.connect(SocketChannelImpl.java:272)
     at org.apache.harmony.nio.internal.PipeImpl$SinkChannelImpl.finishConnect(PipeImpl.java:164)
     at org.apache.harmony.nio.internal.PipeImpl.<init>(PipeImpl.java:48)
     at org.apache.harmony.nio.internal.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:51)
     at org.apache.harmony.nio.internal.SelectorImpl.<init>(SelectorImpl.java:141)
     at org.apache.harmony.nio.internal.SelectorProviderImpl.openSelector(SelectorProviderImpl.java:58)
     at com.sejin.NwTestActivity.onCreate(NwTestActivity.java:42)
     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
     at android.os.Handler.dispatchMessage(Handler.java:99)
     at android.os.Looper.loop(Looper.java:123)
     at android.app.ActivityThread.main(ActivityThread.java:4627)
     at java.lang.reflect.Method.invokeNative(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:521)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
     at dalvik.system.NativeStart.main(Native Method)
--------------------------

I did googling, someone said JRE 1.6 bug on Vista or address problem between IPv4 and IPv6. But i don't think that.
First, My environment is not VISTA.
Second, as the logs I just open NIO selector not connecting to some addresses.


Jun 30, 2010
#1 rednos...@gmail.com
My code is simple..

Selector mySelector = Selector.open();

I tried this code below, but the result was same

AbstractSelector mySelector = SelectorProvider.provider().openSelector();
Jul 1, 2010
Project Member #2 e...@google.com
this is on the emulator? the emulator doesn't support IPv6.
Owner: e...@google.com
Labels: Component-Dalvik
Jul 1, 2010
#3 rednos...@gmail.com
I have a test device that doesn't start to release. It's OS is Froyo and this situation is same. As you comment, the problem is the device doesn't support IPv6. 
I wonder how can a application detact it's device support IPv6 or not. 
Is there a way that I can use Java NIO(specially Selector), if the device support IPv6 or not?
Jul 2, 2010
Project Member #4 e...@google.com
i believe you can't pass CTS without IPv6 support, so it might be easiest if you just hassle your kernel guys right away.

we have a bug to rewrite Pipe to not use an internet socket at all, but that doesn't help you right now.

if you want a hack so you can get some work done while you wait for your kernel guys, i'd suggest you look at PipeImpl; if you had an InetSocketAddress whose InetAddress was the IPv4 loopback address rather than the IPv6 loopback address it currently asks for...
Jul 4, 2010
#5 rednos...@gmail.com
thank you for comments.

Could you tell me, when does the bug fix in Android 2.2? Do you have some plan?
If the bug remains in Android 2.2, application developers can't use Java NIO (Selector), I think. At least, you should recommand this to Selector reference pages on Android reference site.

Jul 5, 2010
#6 xinxi...@gmail.com
I also have Selector issues while working with Froyo. The system will throw a NullPointerException when i try to call Selector.wakeup(), but the same code works perfect in all previous releases on Android platform.

It seems that Froyo has some bugs in its selector implementation.
Jul 7, 2010
Project Member #7 e...@google.com
@5: rewriting Pipe to not use an internet socket will not happen in froyo. i don't know what release it will happen in. developers can still use Selector; they just need an IPv6-enabled kernel. all devices need an IPv6-enabled kernel to pass CTS anyway.

@6: please file a separate bug with a reproduceable test case.
Summary: [Android 2.2] Java NIO Selector open fails on devices without IPv6 support (SocketException)
Jul 8, 2010
#8 mea...@gmail.com
My device does not support ipv6, the following works for me (YMMV/nothing guaranteed/...)

Change vm/Properties.c
 setProperty(propObj, put, "java.net.preferIPv6Addresses", "true");
to 
 setProperty(propObj, put, "java.net.preferIPv6Addresses", "false");

If CTS passing is needed for you, you still have a problem.
Aug 3, 2010
Project Member #9 e...@google.com
fixed internally to use pipe(2) rather than an internet socket.
Status: FutureRelease
Nov 30, 2010
#10 abdulla....@gmail.com
work around:

    		java.lang.System.setProperty("java.net.preferIPv4Stack", "true");
    		java.lang.System.setProperty("java.net.preferIPv6Addresses", "false");

Dec 6, 2010
Project Member #11 e...@google.com
(No comment was entered for this change.)
Status: Released
Labels: Target-Gingerbread
Dec 3, 2012
Project Member #12 e...@google.com
(No comment was entered for this change.)
Labels: Restrict-AddIssueComment-Commit
Sign in to add a comment

Powered by Google Project Hosting