question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to create any port mapping.

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:27 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
sved-drycommented, Apr 11, 2020

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.

0reactions
sved-drycommented, Apr 12, 2020

Thank you for your help on this. Happy to help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

upnp: Unable to create port mappings for specific ports (in ...
Folks, It seems it is impossible to create UPnP port mappings for some specific ports that seem to be in use at the...
Read more >
Unable to create port mappings in DC++ with MiniUPnP ...
[17:35] Port mapping: Failed to create port mappings. I tried to select a specific network interface in the settings, disable all network ...
Read more >
Question #212134 “Port mapping failed...” - Launchpad Answers
I live in a students residence, so I don't have access to a router. There is a hub that can just be connected...
Read more >
Docker port forwarding not working
I have setup Docker container for access my machine docker container to another machine in local. Create a container below command: docker run...
Read more >
Can't connect to container on localhost with port mapping
I'm trying torun a windows container on my windows machine. and would like to connect to it via localhost. For example the container...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found