Open.NAT
Open.NAT copied to clipboard
Exception of type 'Open.Nat.NatDeviceNotFoundException' was thrown.
Here's my code:
using System;
using System.Net;
using System.Threading;
using Open;
using Open.Nat;
namespace CPortOpener
{
class MainClass
{
public static void Main (string[] args)
{
openPort ();
Console.ReadLine ();
}
public static async void openPort ()
{
try
{
var discoverer = new NatDiscoverer();
var cts = new CancellationTokenSource(15000);
var device = await discoverer.DiscoverDeviceAsync(PortMapper.Upnp, cts);
await device.CreatePortMapAsync(new Mapping(Protocol.Tcp, 1600, 1700, "The mapping name"));
}
catch (Exception ex)
{
Console.WriteLine (ex.Message);
}
}
}
}
I'm getting this Exception:
Exception of type 'Open.Nat.NatDeviceNotFoundException' was thrown.
@Mmokhtar that means it wasn't able to find any UPnp NAT device in your network. If you are sure it should have found one, please share the logs with me and i will review it asap.
Hello again Mr Ontivero,
I'm getting same error when I start to app with VS. But most of time when I start to exe on bin/debug/ConsoleTest.exe, app found device with there is no throwing errors.
I don't know why cannot found on VS but maybe you need check something Async Functions. Maybe some breakpoints could be causing this.
Have a good day, good works...