Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

Troubleshooting

lontivero edited this page Apr 29, 2015 · 1 revision

Using Open.Nat.ConsoleTest project

The Open.Nat solution includes the Open.Nat.ConsoleTest project that can be used for Troubleshooting. Just download the code and run it.

Your IP: 181.110.171.21
Added mapping: 181.110.171.21:1700 -> 127.0.0.1:1600Mapping List
+------+-------------------------------+--------------------------------+----------------------------------+
| PROT | PUBLIC (Reacheable)           | PRIVATE (Your computer)        | Descriptopn                      |
+------+----------------------+--------+-----------------------+--------+----------------------------------+
|      | IP Address           | Port   | IP Address            | Port   |                                  |
+------+----------------------+--------+-----------------------+--------+----------------------------------+
|  TCP | 181.110.171.21       |  21807 | 10.0.0.5              |  32400 | Plex Media Server                |
|  UDP | 181.110.171.21       |  25911 | 10.0.0.6              |  25911 | Skype UDP at 10.0.0.6:25911 (2693)|
|  TCP | 181.110.171.21       |  25911 | 10.0.0.6              |  25911 | Skype TCP at 10.0.0.6:25911 (2693)|
|  TCP | 181.110.171.21       |   1700 | 10.0.0.6              |   1600 | Open.Nat Testing                 |
+------+----------------------+--------+-----------------------+--------+----------------------------------+
[Removing TCP mapping] 181.110.171.21:1700 -> 127.0.0.1:1600
[Done]
[SUCCESS]: Test mapping effectively removed ;)
Press any kay to exit...

Read more about ConsoleTest

Enabling tracing in your project

Open.Nat provides its own TraceSource in order to enable applications to trace the execution of the library's code and find issues. To enable the tracing you can add the following two lines of code:

NatUtility.TraceSource.Switch.Level = SourceLevels.Verbose;
NatUtility.TraceSource.Listeners.Add(new ConsoleListener());

The first line specifies the tracing level to use and the levels used by Open.Nat are: Verbose, Error, Warning and Information. You should set it to Information first and switch to Verbose if erros occur. The scond line add a trace listener and you can choose the one that is better for you, some of the available listeners are:

Code Example

Here you can see a code snippet used to get the external IP Address.

NatUtility.TraceSource.Switch.Level = SourceLevels.Information;
NatUtility.TraceSource.Listeners.Add(new ColorConsoleListener());

NatUtility.DeviceFound += (sender, args) => {
    Console.WriteLine("It got it!!");
    var ip = await device.GetExternalIPAsync();
    Console.WriteLine("The external IP Address is: " + ip);
};

NatUtility.Initialize();
NatUtility.StartDiscovery();

And here, the tracing output:

OpenNat - Information > Initializing
OpenNat - Information > StartDiscovery
OpenNat - Information > Searching
OpenNat - Information > Searching for: UpnpSearcher
OpenNat - Information > UPnP Response: Router advertised a 'WANPPPConnection:1' service!!!
OpenNat - Information > Found device at: http://10.0.0.2:5431/dyndev/uuid:0000e068-20a0-00e0-20a0-48a8000808e0
OpenNat - Information > 10.0.0.2:5431: Fetching service list
OpenNat - Information > 10.0.0.2:5431: Parsed services list
OpenNat - Information > 10.0.0.2:5431: Found service: urn:schemas-upnp-org:service:Layer3Forwarding:1
OpenNat - Information > 10.0.0.2:5431: Found service: urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1
OpenNat - Information > 10.0.0.2:5431: Found service: urn:schemas-upnp-org:service:WANPPPConnection:1
OpenNat - Information > 10.0.0.2:5431: Found upnp service at: /uuid:0000e068-20a0-00e0-20a0-48a802086048/WANPPPConnection:1
OpenNat - Information > 10.0.0.2:5431: Handshake Complete
OpenNat - Information > UpnpNatDevice device found.
OpenNat - Information > ---------------------VVV
EndPoint: 10.0.0.2:5431
Control Url: http://10.0.0.2:5431/uuid:0000e068-20a0-00e0-20a0-48a802086048/WANPPPConnection:1
Service Description Url: http://10.0.0.2:5431/dyndev/uuid:0000e068-20a0-00e0-20a0-48a8000808e0
Service Type: urn:schemas-upnp-org:service:WANPPPConnection:1
Last Seen: 15/05/2014 10:43:23 p.m.
It got it!!
The external IP Address is: 186.108.237.5
OpenNat - Information > UPnP Response: Router advertised a 'WANPPPConnection:1' service!!!
OpenNat - Information > Found device at: http://10.0.0.2:5431/dyndev/uuid:0000e068-20a0-00e0-20a0-48a8000808e0
OpenNat - Information > Already found - Ignored
Clone this wiki locally