Mono.Nat: Unable to create any port mapping.

Hi,

I would like to use Mono Nat to open a UDP port for an app I am developing. When trying to create a port mapping, I get the following exception “Mono.Nat.MappingException: Error ConflictInMappingEntry”. I get this exception for any port number I try, regardless of udp/tcp. I see the following output for my log statement regarding Device details:

Device details: Upnp 4/4/2020 5:09:20 PM 192.168.1.1:49808

My router is Asus CM_AC2600 and upnp is enabled. Any ideas on where to go next? Router is reachable and has the services needed as far as i can tell. Code is attached below:

<deviceType>urn:schemas-upnp-org:device:WANDevice:1</deviceType> <friendlyName>WANDevice</friendlyName> <manufacturer>MiniUPnP</manufacturer>

private Mapping _currentMapping;
public int MIN_PORT => 42500;
public int MAX_PORT => 42900;
private void DeviceFound(object sender, DeviceEventArgs args)
        {
            Debug.Log("Device Found");
            INatDevice device = args.Device;

            Debug.Log($"Device details: {device.NatProtocol} {device.LastSeen} {device.DeviceEndpoint}");
            try
            {
                for (int i = MIN_PORT; i < MAX_PORT; i++)
                {
                    try
                    {
                        _currentMapping = device.CreatePortMap(new Mapping(Mono.Nat.Protocol.Udp, i, i));
                        break;
                    }
                    catch (Exception e)
                    {
                        Debug.Log($"port {i} in use, still scanning for port to open..., {e}");
                    }
                }
                
                Debug.Log($"We got map of public, {_currentMapping.PublicPort} private {_currentMapping.PrivatePort}");

            }
            catch (Exception e)
            {
                Debug.Log($"exception device: {e}");
            }
        }

Mono.Nat.MappingException: Error ConflictInMappingEntry: ConflictInMappingEntry at Mono.Nat.Upnp.ResponseMessage.Decode (Mono.Nat.Upnp.UpnpNatDevice device, System.String message) [0x0009e] in <bb7a49cf350d4cdf92cc79833d23f455>:0 at Mono.Nat.Upnp.UpnpNatDevice+<DecodeMessageFromResponse>d__21.MoveNext () [0x001b6] in <bb7a49cf350d4cdf92cc79833d23f455>:0 — End of stack trace from previous location where exception was thrown — at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <599589bf4ce248909b8a14cbe4a2034e>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <599589bf4ce248909b8a14cbe4a2034e>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <599589bf4ce248909b8a14cbe4a2034e>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <599589bf4ce248909b8a14cbe4a2034e>:0 at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in <599589bf4ce248909b8a14cbe4a2034e>:0 at Mono.Nat.Upnp.UpnpNatDevice+<SendMessageAsync>d__17.MoveNext () [0x00340] in <bb7a49cf350d4cdf92cc79833d23f455>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <599589bf4ce248909b8a14cbe4a2034e>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <599589bf4ce248909b8a14cbe4a2034e>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <599589bf4ce248909b8a14cbe4a2034e>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <599589bf4ce248909b8a14cbe4a2034e>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <599589bf4ce248909b8a14cbe4a2034e>:0 at Mono.Nat.Upnp.UpnpNatDevice+<CreatePortMapAsync>d__12.MoveNext () [0x00083] in <bb7a49cf350d4cdf92cc79833d23f455>:0 — End of stack trace from previous location where exception was thrown — at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <599589bf4ce248909b8a14cbe4a2034e>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <599589bf4ce248909b8a14cbe4a2034e>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <599589bf4ce248909b8a14cbe4a2034e>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <599589bf4ce248909b8a14cbe4a2034e>:0 at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <599589bf4ce248909b8a14cbe4a2034e>:0 at Mono.Nat.NatDeviceExtensions.CreatePortMap (Mono.Nat.INatDevice device, Mono.Nat.Mapping mapping) [0x0000d] in <bb7a49cf350d4cdf92cc79833d23f455>:0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 27 (11 by maintainers)

Most upvoted comments

I have it enabled. And it gives us the same error. No worries, I think the next step for me is to either contact Asus or to try NAT hole punching instead.