offbynull / portmapper

Java library that maps ports on NAT-enabled routers (supported protocols: UPnP-IGD/NAT-PMP/PCP).
Apache License 2.0
90 stars 17 forks source link

Caused by java.net.ConnectException #37

Open jefryjacky opened 6 years ago

jefryjacky commented 6 years ago

keep crashing my android app, below is the exception

Fatal Exception: java.lang.RuntimeException java.net.ConnectException: failed to connect to /fe80::12be:f5ff:fe1a:d414 (port 49152): connect failed: EINVAL (Invalid argument) com.offbynull.portmapper.gateways.network.NetworkRunnable.run (SourceFile:134) java.lang.Thread.run (Thread.java:818)

Caused by java.net.ConnectException failed to connect to /fe80::12be:f5ff:fe1a:d414 (port 49152): connect failed: EINVAL (Invalid argument) libcore.io.IoBridge.connect (IoBridge.java:124) arrow_drop_down java.nio.SocketChannelImpl.connect (SocketChannelImpl.java:199) com.offbynull.portmapper.gateways.network.NetworkRunnable.processMessage (SourceFile:366) com.offbynull.portmapper.gateways.network.NetworkRunnable.run (SourceFile:127) java.lang.Thread.run (Thread.java:818)

Caused by android.system.ErrnoException connect failed: EINVAL (Invalid argument) libcore.io.Posix.connect (Posix.java) libcore.io.BlockGuardOs.connect (BlockGuardOs.java:111) libcore.io.IoBridge.connectErrno (IoBridge.java:137) libcore.io.IoBridge.connect (IoBridge.java:122) libcore.io.IoBridge.connect (IoBridge.java:110) java.nio.SocketChannelImpl.connect (SocketChannelImpl.java:199) arrow_right com.offbynull.portmapper.gateways.network.NetworkRunnable.processMessage (SourceFile:366) com.offbynull.portmapper.gateways.network.NetworkRunnable.run (SourceFile:127) java.lang.Thread.run (Thread.java:818)

offbynull commented 6 years ago

This looks like a core OS error. What phone maker/model? What version of Android?

Do you have logs? You need to add in an android logger for slf4j and enable trace logging.

jefryjacky commented 6 years ago

Hi, The crash is at NetworkRunnable class line 366 ==> channel.connect(dst);

Crash happened on this phone:

  1. phone model: asus ZenFone 2 (ZE550ML) OS: Android 5.0

  2. phone model: Huawei Nexus 6P OS: Android 8.0.0

I have tested it on Samsung Galaxy Duos Android 4.2.2 and Emulator Android 8.0.0, it's not crashing my app.

I don't have a log for this issue now.

offbynull commented 6 years ago

I can wrap the connect call in a try/catch and have it ignore errors, but there's probably something wrong with how the Android build was set up or how the parsing of OS commands is happening. If you can get logs, it would help me with finding what the core issue is.

jefryjacky commented 6 years ago

Ok, I will get the log for you later.

jefryjacky commented 6 years ago

Hi @offbynull ,

Here is the log, Log nexus.txt

offbynull commented 6 years ago

Thanks. I'll take a look at this shortly.

foralllove commented 4 years ago

did you find the problem

offbynull commented 4 years ago

It's hard to narrow down without access to the device. If you're encountering problems, your best bet is to debug it and submit a patch. I don't have as much free time anymore to put into this project.