1. Are you ready for the Galaxy S20? Here is everything we know so far!

Socket exception Permission denied in VirtualBox (with Ubuntu) from Device

Discussion in 'Android Development' started by mdsousa, Oct 6, 2020.

  1. mdsousa

    mdsousa Newbie
    Thread Starter

    Hi

    I'm running Android Studio 4.0.1 (it has api 27, 28 and 29 installed). The physical device is a Samsung Active2 (Model SM-T390) and has Android version 9 (api 28) on it.

    I am running Android Studio in a Virtualbox (version 6.1) with Ubuntu 20.04 installed in it. The Virtualbox is running on Windows 10. There is some port forwarding being done in the Virutalbox as seen in the pic below
    upload_2020-10-6_11-22-18.png


    When trying to open an AsynchronousSocketChannel, it throws an exception and complains about 'Permission denied', the stack trace is here (relevant lines are bold):
    Code (Text):
    1.  
    2. aunching 'app' on samsung SM-T390.
    3. $ adb shell am start -n "com.elbit.elbittoandroidtest/com.elbit.edmandroidtest.EDMtoAndroidTest" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
    4. Connected to process 17757 on device 'samsung-sm_t390-5200bd485e8766fd'.
    5. Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
    6. I/ittoandroidtes: The ClassLoaderContext is a special shared library.
    7. I/MultiWindowDecorSupport: updateCaptionType >> com.android.internal.policy.MultiWindowDecorSupport@a6ae311, isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true
    8. D/MultiWindowDecorSupport: setCaptionType = 0
    9. W/ittoandroidtes: Accessing hidden method Landroid/graphics/drawable/Drawable;->getOpticalInsets()Landroid/graphics/Insets; (light greylist, linking)
    10. W/ittoandroidtes: Accessing hidden field Landroid/graphics/Insets;->left:I (light greylist, linking)
    11.     Accessing hidden field Landroid/graphics/Insets;->right:I (light greylist, linking)
    12.     Accessing hidden field Landroid/graphics/Insets;->top:I (light greylist, linking)
    13.     Accessing hidden field Landroid/graphics/Insets;->bottom:I (light greylist, linking)
    14. D/NetworkManagementSocketTagger: tagSocket(-1) with statsTag=0xffffffff, statsUid=-1
    15. I/AsynchronousSocketChannel IOException: java.net.SocketException: Permission denied
    16.         at sun.nio.ch.Net.socket0(Native Method)
    17.         at sun.nio.ch.Net.socket(Net.java:420)
    18.         at sun.nio.ch.Net.socket(Net.java:413)
    19.         at sun.nio.ch.AsynchronousSocketChannelImpl.<init>(AsynchronousSocketChannelImpl.java:90)
    20.         at sun.nio.ch.UnixAsynchronousSocketChannelImpl.<init>(UnixAsynchronousSocketChannelImpl.java:102)
    21.         at sun.nio.ch.LinuxAsynchronousChannelProvider.openAsynchronousSocketChannel(LinuxAsynchronousChannelProvider.java:88)
    22.         at java.nio.channels.AsynchronousSocketChannel.open(AsynchronousSocketChannel.java:169)
    23.         at java.nio.channels.AsynchronousSocketChannel.open(AsynchronousSocketChannel.java:190)
    24.         at (EDMtoAndroidTest.java:101)
    25.         at android.app.Activity.performCreate(Activity.java:7335)
    26.         at android.app.Activity.performCreate(Activity.java:7326)
    27.         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1275)
    28.         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3121)
    29.         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3284)
    30.         at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    31.         at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    32.         at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    33.         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1972)
    34.         at android.os.Handler.dispatchMessage(Handler.java:106)
    35.         at android.os.Looper.loop(Looper.java:214)
    36.         at android.app.ActivityThread.main(ActivityThread.java:7179)
    37.         at java.lang.reflect.Method.invoke(Native Method)
    38.         at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
    39.         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
    40. W/System.err: java.net.SocketException: Permission denied
    41.         at sun.nio.ch.Net.socket0(Native Method)
    42. W/System.err:     at sun.nio.ch.Net.socket(Net.java:420)
    43.         at sun.nio.ch.Net.socket(Net.java:413)
    44.         at sun.nio.ch.AsynchronousSocketChannelImpl.<init>(AsynchronousSocketChannelImpl.java:90)
    45.         at sun.nio.ch.UnixAsynchronousSocketChannelImpl.<init>(UnixAsynchronousSocketChannelImpl.java:102)
    46. W/System.err:     at sun.nio.ch.LinuxAsynchronousChannelProvider.openAsynchronousSocketChannel(LinuxAsynchronousChannelProvider.java:88)
    47.         at java.nio.channels.AsynchronousSocketChannel.open(AsynchronousSocketChannel.java:169)
    48.         at java.nio.channels.AsynchronousSocketChannel.open(AsynchronousSocketChannel.java:190)
    49.         at android.app.Activity.performCreate(Activity.java:7335)
    50.         at android.app.Activity.performCreate(Activity.java:7326)
    51.         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1275)
    52.         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3121)
    53. W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3284)
    54.         at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    55.         at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    56.         at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    57.         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1972)
    58. W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:106)

    The line of code referred to in the exception stack trace is here:
    Code (Java):
    1.  
    2.         try
    3.         {
    4. [B][SIZE=5]            java.nio.channels.AsynchronousSocketChannel client = java.nio.channels.AsynchronousSocketChannel.open(); // this is [B]EDMtoAndroidTest.java:101[/B][/SIZE][/B]
    5. //            InetSocketAddress host = new InetSocketAddress("127.0.0.1",1870);
    6.             InetSocketAddress host = new InetSocketAddress("10.0.2.2",1870);
    7.             Future<Void> future = client.connect(host);
    8.             future.get(); // wait for connection to succeed
    9.             Log.i("AsynchronousChannel", "Connection Successful");
    10.         catch (InterruptedException e)
    11.         {
    12.             Log.i("AsynchronousSocketChannel IOException", Log.getStackTraceString(e));
    13.             e.printStackTrace();
    14.         }
    15.  
    Any idea what I am missing when trying to get a physical device to open a socket to Ubuntu running in a Virtualbox which it self is running on Windows 10?

    Thanks...
     


    MrJavi likes this.
Loading...
Similar Threads - Socket exception Permission
  1. mdsousa
    Replies:
    0
    Views:
    148
  2. Ashish87
    Replies:
    0
    Views:
    191
  3. mdsousa
    Replies:
    0
    Views:
    470
  4. Pravinkumar Putta
    Replies:
    2
    Views:
    635
  5. Anaya Omkar Joshi
    Replies:
    1
    Views:
    158
  6. David Pesetsky
    Replies:
    4
    Views:
    421
  7. The Juan
    Replies:
    0
    Views:
    184
  8. Alvaro Vargas
    Replies:
    2
    Views:
    992
  9. sunil_333
    Replies:
    0
    Views:
    326
  10. zthanxx
    Replies:
    0
    Views:
    478

Share This Page

Loading...