I'm getting extremely long delays (10~30 seconds) in SQL Server Management Studio 2014 when attempting to connect to a SQL Server 2012 instance over TCP using Windows Authentication. This happens when connecting Object Explorer or a new blank query window. Once connected, running queries is fast. The problem does not happen when I connect using SQL Server authentication.

Environment:

  • Windows 7, logged in as a domain user
  • TCP connection via IP address (not hostname)
  • The server is at a remote location connected via VPN
  • No encryption

When I logged into a co-worker's Windows 7 computer with my domain account, and connected to the same SQL Server through the same VPN, there was no delay. When the same co-worker logged into my PC with his own domain account, he experienced the delay. These tests show that the problem is unique to my PC. Also, the problem only appears when connecting to this specific SQL Server and VPN; I can connect to other SQL Servers on the local network via Windows Authentication without any delay.

Things I've tried with no success:

  • Disabled anti-virus and firewall
  • Renamed the "12.0" folder under "%userprofile%\AppData\Roaming\Microsoft\SQL Server Management Studio" to "_12.0" to force SSMS to recreate my user settings.
  • Force Network protocol to TCP rather than <default>. I also tried Named Pipes but my server isn't setup for that.
  • Installed SSMS 2012 and tried that instead of 2014.
  • Disabled IPv6
  • Blackholed crl.microsoft.com to 127.0.0.1 in my etc\hosts file.
  • Disabled the Customer Experience Improvement Program in SSMS, Visual Studio, and Windows.
  • Uninstalled all SQL Server related apps from my PC and reinstalled just 2012.

TCPView clues:

  • Using TCPView, I noticed that when I make a new connection, its state becomes ESTABLISHED right away, but then one or two more connections with the SQL Server are continually attempted and closed with TIME_WAIT. On my co-worker's computer, these connections are ESTABLISHED and solid. So I'm pretty sure this is the source of the timeouts, but what are the connections for, and why do they fail? (I don't have any addons in my SSMS.)

Any ideas?

Update: Intellisense/Autocomplete clue(?):

I noticed that once I finally do connect, Intellisense/Autocomplete doesn't work. Do those require separate connections from SSMS? I tried disabling them, and it didn't seem to resolve the long connection delay.

  • Have you tried running SSMS with the /log switch? – Mister Magoo Jun 17 '15 at 23:20
  • @MisterMagoo trying that now. It doesn't actually log anything about its connection attempts (the file doesn't grow when making a new connection). It's mostly stuff about loading certain packages in the UI, e.g. "Successfully loaded component assembly from cache". I couldn't find any errors or exceptions. – Jordan Rieger Jun 17 '15 at 23:28
  • Ok, I wasn't sure if it would, but figured it was worth a quick try. If you are really interested in what is going on, you might need to break out Sysinternals Process Monitor and see if you can identify what is going on. technet.microsoft.com/en-us/library/bb896645.aspx – Mister Magoo Jun 18 '15 at 22:22
  • I've been poring over ProcMon dumps for about an hour, but there's just so many events (even filtered down to Ssms.exe) that I can't make much of it. – Jordan Rieger Jun 19 '15 at 23:38
  • @MisterMagoo All I can see is that the connection attempts that I saw with TcpView are indeed taking a long time (over 5 seconds each). I'm basing that on seeing the "TCP Connect" event on a particular local port, and then the next time I see anything sent or received on that local port is always after at least 5 seconds. – Jordan Rieger Jun 19 '15 at 23:46
up vote 17 down vote accepted
+100

Try running a trace with SQL Profiler while you, and then your coworker, connect to the server.
Select RPC, SQL Statement & PreConnect - Starting/Completed.
Select Save Results To Table option, then compare the 2 tables to find the bottleneck.

Or, since you're connecting by IP, it could be doing a Reverse DNS lookup. If so, add a entry in your hosts file.

  • 2
    I added a local etc/hosts entry for the IP address of my server, then tried SSMS again. Bingo! Super fast. Thank you! (I left SSMS connecting via IP address as before, not hostname.) I'm just wondering why I need this workaround but my co-workers don't. It does seem to be DNS related. In any case, this is a pretty good solution for me, so I will award you the bounty once you update your answer. – Jordan Rieger Jun 22 '15 at 17:55
  • I think it was the reverse lookup because when I removed the hosts entry, ping - a ###.###.###.### was very slow before the first ping (paused 5 seconds for the reverse lookup.) When added back the hosts entry, ping -a was fast. There was no difference in the tracert or nslookup though. I think something must be different on my PC that is causing me to do the reverse lookup when my co-workers are not (or it's just much faster on theirs.) BTW, my Intellisense works again now that the connection speed is fast. – Jordan Rieger Jun 23 '15 at 0:50
  • Even a fake DNS entry for the IP in the hosts file makes this work much faster! Thank you! – felickz Jan 22 '16 at 19:10
  • I was getting timeouts trying to connect SSMS across a VPN until I read your answer, yes it makes sense because I was connecting to the server via IP and name resolution wasn't working. Adding an entry in the host file finally made it work after many hours trying to get this working. Thanks! As a footnote I want to say that I am using Windows authentication from different domains with the runas /netonly and it works fine with this solution. – RobbZ Feb 12 '16 at 14:55
  • The site referenced is now a spam site - maybe remove the link. – Dale Burrell May 19 '17 at 0:12

What you should check first is your server or client DNS settings

It's not the rare that your SQL Server have the problem connecting to Active Directory. If you try with local Windows account I am sure that you will not have the at issue. It's not unusual that server is configured with public internet DNS and when SQL Server connects to DC to check the credentials and verify it, it will try top contact the public DNS instead of the DNS server of the AD. Since this information is not stored on the public DNS it will fail to verify and this will cause the delay until it manage to contact the proper DNS server or DC via the NTLM

Since you are not experiencing the problem with other SQL Servers, than almost certainly the issue is not related to AD or DC configurations

Fire the IPConfig.exe /all command from the cmd to check the configured DNS servers. You should have only AD's DNS servers configured. Remove all public DNS servers, and leave just AD's DNS servers.

  • Are you suggesting that the SQL Server is contacting a public DNS to lookup the IP address of the Domain Controller, and that is causing the delay when it attempts to validate my Windows Authentication? If that's the case, why would it work fine from my co-worker's PC on the same local network, over the same VPN? I checked the DNS settings on my computer, and there was an extra third DNS server that my IP department had asked me to add, which wasn't present on my co-worker's PC. But when I removed that server, did a ipconfig /flushdns, and tried again, it was still slow. – Jordan Rieger Jun 22 '15 at 17:17
  • Using the IP address or the FQDN of the server (not just the hostname) made a huge differnce for me. Was definitely a slow DNS issue in my case. – userSteve Oct 3 '16 at 11:24

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.