offbynull / portmapper

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

Request for usage #23

Closed ga67vib closed 8 years ago

ga67vib commented 8 years ago

Hi,

some friends and me are writing a peer-to-peer messenger, and need a way of traversing NAT. Your port mapper seems like a pretty neat tool for that.

Two questions: May we use it? Is it currently working? Because one of the last commit messages is "WIP -- PROJECT IS BROKEN", so I assume it is broken.

Best regards Maxi

offbynull commented 8 years ago

Hi,

  1. You're more than welcome to use it in your project.
  2. The work referenced by the WIP message was completed and the product was released to maven central.

If you have any problems using it or you notice a bug, don't hesitate to open a ticket.

ga67vib commented 8 years ago

Hey,

we downloaded a version of your tool at Maven (http://mvnrepository.com/artifact/com.offbynull.portmapper/portmapper/2.0.0), but it reported a ClassNotFoundError. By downloading the compile dependencies, we fixed that, but now it reports:

"[Thread-3] INFO com.offbynull.portmapper.mappers.upnpigd.UpnpIgdPortMapper - Attempting to identify devices [Network IO] ERROR com.offbynull.portmapper.gateways.network.NetworkRunnable - 1 Exception encountered java.net.SocketException: No buffer space available (maximum connections reached?): no further information"

The way we are using your code is as you describe it in the Quick-Start Guide (we actually just copy-pasted the code into a method, and have a thread that is running that method)

Is that information enough, to identify the problem?

offbynull commented 8 years ago

Hi,

Sorry for the delay. That error message is very likely benign and can be ignored. It happens on my machine too.

The library runs some OS-specific processes and parses IPs out of the outputs to determine gateway addresses (this is how PCP and NAT-PMP servers are identified). Some of the IPs that get parsed out are invalid, and that exception is given back when you try to connect/send/bind to one of those IPs. The exception is logged and the code moves on. It isn't a critical failure.

When you run the example code...

List<PortMapper> mappers = PortMapperFactory.discover(networkBus, processBus);

Is mappers empty? If so, do you...

a) have a router between the machine you're on? b) does that router have support for at least one of the following: UPnP-IGD or PCP or NAT-PMP? c) does that router have port mapping enabled? d) are you using windows firewall or some other firewall that restricts the java process from sending packets outside? e) are you running the code on a VM? if you are, depending on the network type the VM is using you won't be able to reach your router.

If you double checked all these things, we can maybe screenshare via hangouts or skype and I can help diagnose the issue you're having.

ga67vib commented 8 years ago

Thank you very much for your help and advice!

My friends and me will meet up again in the following weeks, and try your suggestions. If we still face problems then, we will contact you again.