Tim Perry
Tim Perry

Reputation: 13266

What could cause intermittent 'Permissions Denied' errors in DatagramChannel connect() calls on Android?

I'm seeing intermittent error reports from my end users' devices like:

java.net.ConnectException: Permission denied
    at sun.nio.ch.Net.connect0(Net.java)
    at sun.nio.ch.Net.connect(Net.java:466)
    at sun.nio.ch.DatagramChannelImpl.connect(DatagramChannelImpl.java:759)
    at tech.httptoolkit.android.vpn.SessionManager.createNewUDPSession(SessionManager.java:159)

That last line is here: https://github.com/httptoolkit/httptoolkit-android/blob/2d514dce3079d23b7a500580b202ae4f7767eaaa/app/src/main/java/tech/httptoolkit/android/vpn/SessionManager.java#L152.

The application does already request INTERNET permission, and connections do work in general, they just fail like this intermittently.

I don't have much more information on the exact request that's failing, and I can't easily reproduce the issue myself for testing, so I'm debugging blind.

What are the possible causes of this error?

Upvotes: 0

Views: 145

Answers (1)

G. Ciardini
G. Ciardini

Reputation: 1307

It is being refused permission to connect, by the local operating system.

  • IPv6 support was added in Java 1.4
  • There's been issues with IPv6 (on Java 7)

Try to disable IPv6 on both server and client machines. (For android you can select IPv4, inside your "Mobile network" under the voice "APN Protocol")

Upvotes: 1

Related Questions