Obsah

Dynamics NAV 2013 R2

How to share same port between multiple instances

If you want to share same port between multiple instances on the same server you have to do these steps:

  1. Create multiple instances in NAV using same port (7046 is default)
  2. Stop all NAV instances
  3. Enable Net.TCP Port Sharing service (by default is startup Disabled): Set startup to automatic
  4. On each NAV instance's service add dependency on Net TCP port sharing service:
    sc config MicrosoftDynamicsNavServer$NavInstanceName depend= NetTcpPortSharing/HTTP
  5. If you are running NAV as your domain based service account (which you should) find out its SID:
    wmic useraccount where (name='service-account-login' and domain='%userdomain%') get name,sid
  6. Find out which config file is used for port sharing service:
    1. Open Service details of Net.TCP Port Sharing Service
    2. Check Path to executable
    3. Append .config to the path
  7. Edit this config file by adding:
    <system.serviceModel.activation>
       <net.tcp listenBacklog="10" maxPendingConnections="100" maxPendingAccepts="2" receiveTimeout="00:00:10" teredoEnabled="false">
                <allowAccounts>
                    <add securityIdentifier="--SID of your service account--"/>
                </allowAccounts>
        </net.tcp>
    </system.serviceModel.activation>
  8. Restart all services depending on SMSvcHost.exe executable to reload with new .config configuration (or to be sure whole server).
  9. Start all NAV instances, now they should be using same configured port without any error.

Errors that you can see

Only one usage of each socket address

The service MicrosoftDynamicsNavServer$ApsTest failed to start. This could be caused by a configuration error. Detailed error information:System.ServiceModel.AddressAlreadyInUseException: There is already a listener on IP endpoint 0.0.0.0:7046. This could happen if there is another application already listening on this endpoint or if you have multiple service endpoints in your service host with the same IP endpoint but with incompatible binding configurations. ---> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted

This error occurs when you forgot to add dependency on NetTcpPortSharing service on your NAV instances services.

Access denied

The service MicrosoftDynamicsNavServer$ApsTest failed to start. This could be caused by a configuration error. Detailed error information:System.ServiceModel.CommunicationException: The service endpoint failed to listen on the URI 'net.tcp://server:7046/ApsTest/Service' because access was denied.  Verify that the current user is granted access in the appropriate allowAccounts section of SMSvcHost.exe.config. ---> System.ComponentModel.Win32Exception: Access is denied

This error occurs when you forgot to add SID of your system account to the SMSvcHost.exe.config file or if you update wrong config file (there are multiple files with this name on the server).

Sources