Search code examples
javascriptjnditeamviewer

Teamviewer conflicted with JNDI - use higher port numbers for outgoing (win7)


Teamviewer established an outgoing connection using the local port 1098 which is also the JNDI port.

I spent 2 hours until I realized what the error was because I was focusing in the resulting exceptions, e.g. :

Exception: javax.transaction.NotSupportedException: Cannot set transactional mode, error is setAutoCommit() is not allowed - use TransactionHelper instead
    javax.transaction.NotSupportedException: 

Cannot set transactional mode, error is setAutoCommit() is not allowed - use TransactionHelper instead
         at daoframework.daofactory.transactions.LocalUserTransaction.begin(LocalUserTransaction.java:78)

Is there any way to block teamviewer from using this port?

Found using:

$ netstat -aon | grep 1098
  TCP    XX.XXX.XX.XX:1098      XXX.XX.XXX.XXX:80      ESTABLISHED     2596

And then looking up the PID in taskmanager.

Update

It seems this more more of a windows 7 problem. In windows vista and beyond:

To comply with Internet Assigned Numbers Authority (IANA) recommendations, Microsoft has increased the dynamic client port range for outgoing connections in Windows Vista and in Windows Server 2008. The new default start port is 49152, and the default end port is 65535. This is a change from the configuration of earlier versions of Windows that used a default port range of 1025 through 5000.

Is there a way to patch windows 7 to use higher port numbers for outgoing connections?

Update2

My windows 7 machine was indeed running with a low port limit.

C:\Windows\system32>netsh int ipv4 show dynamicport tcp

Protocol tcp Dynamic Port Range
---------------------------------
Start Port      : 1025
Number of Ports : 64510

Solution

  • I found the answer from: https://support.microsoft.com/en-us/kb/929851

    You adjust this range by using the netsh command, as follows:

    netsh int <ipv4|ipv6> set dynamic <tcp|udp> start=number num=range
    

    This command sets the dynamic port range for TCP. The start port is number, and the total number of ports is range. The following are sample commands:

    netsh int ipv4 set dynamicport tcp start=10000 num=1000
    netsh int ipv4 set dynamicport udp start=10000 num=1000
    netsh int ipv6 set dynamicport tcp start=10000 num=1000
    netsh int ipv6 set dynamicport udp start=10000 num=1000
    

    Set the range to the following:

    netsh int ipv4 set dynamicport tcp start=49152 num=16384
    

    Finally, even though ephemeral ports should be short lived, an application such as teamviewer may use keep-alive requests and hold onto the port for a much longer time.