Using UPnP-IGD to automatically open a port on the router

I’m currently developing a binding, which requires a inbound connection (event callbacks). One way is to create a port forwarding on the router manually, but this makes the setup for the user more complex than adding a new binding to the existing configuration. So I got the idea to use UPnP and open the port on the router automatically.

The protocol I’m looking for is called IGD (for Internet Gateway Device) and is based on UPNP. It allows a client program (yours) to discover the router on the network (using UPNP) and then ask it to forward a specific port. The are several open source implementations, e.g. https://github.com/offbynull/portmapper

Before I include this jar in my bundle, I would like to understand if there is some existing support in the ESH framework / other bindings/transports to implement this nice feature, which I could use.

The readme of portmapper shows Cling as an alternative.
As ESH uses JUPnP (a fork of Cling), it might not be necessary to use portmapper ar all.

Could you point me to some source code, so I can check weather I could use it. I‘m open to stay as close to the feamework as possible, that avoid compatibility issues.

Shure, ESH Sonos Binding is using UPnP, WeMo binding just for discovery.

Do you know if JUPnP supports IGD?

Google finds nothing on „jupnp port mapping“, but brings up a lot of references to portmapper, so nefore digging in and trying to understand a full upnp implementation…

I checked and found the portmapper implementation in Cling. You could enter a feature request at github JUPnP to implement is as well, should be feasable.

hmm, sounds like a longer way :slight_smile:

not necessarily, as it already exists in cling, one should check were it is refereced and add it to JUPnP.
Might be not as simple as I described it, but feasible. If I would have more time, I would jump in, but not possible atm.

hmm, check the project’s home page, but didn’t saw an option to do a feature request.

Just open it as an issue here