Open.NAT icon indicating copy to clipboard operation
Open.NAT copied to clipboard

Exception of type 'Open.Nat.NatDeviceNotFoundException' was thrown.

Open U-Scripter opened this issue 9 years ago • 2 comments

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.

U-Scripter avatar Feb 01 '16 20:02 U-Scripter

@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.

lontivero avatar Mar 22 '16 04:03 lontivero

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...

UmutComlekci avatar Aug 02 '16 13:08 UmutComlekci