lontivero / Open.NAT

Lightweight and easy-to-use class library to allow port forwarding in NAT devices with UPNP and/or PMP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The thread hangs on CreatePortMapAsync

opened this issue · comments

I've tested in various routers, two of them have shown this specific behavior, but one of two sometimes manages to continue. Upon calling await CreatePortMapAsync, the thread completely blocks, awaiting for the operation to finish. Is it possible there is something wrong and it just takes too long? I've left it for 5 minutes and nothing's happening. Posting the log file and a screenshot of the console.
network.log
console_test

This was happening due to the first device being discovered having a LinkLocal IPv6. The CreatePortAsync would then construct a message to port forward that had that IP, which would result in the Server failed with error: 402.

As it was, you can escape the hanging of the thread by catching the Exception (duh, that was bad of me). In order to find the correct device though, one would need to check if the internal IP of the device is a LinkLocal IPv6. If it is, they should skip that device. Currently you can't find the internal-local IP of a NAT device because it isn't provided in the class and the UPnP and PMP classes are internal. Either add an abstract method for getting the internal IP in the NATDevice or make that check in the DiscoverDevicesAsync.