SQL Server 연결이 가끔 작동 함
ADO.Net 응용 프로그램은 때때로 로컬 네트워크의 다른 서버에 연결할 수 있습니다. 주어진 연결 시도의 성공 여부는 무작위로 보입니다. 연결은 다음 형식의 연결 문자열을 사용합니다.
서버 = THESERVER \ TheInstance; Database = TheDatabase; User Id = TheUser; Password = ThePassword;
반환 된 오류는 다음과 같습니다.
연결 시간이 만료되었습니다. 사전 로그인 핸드 셰이크 승인을 사용하는 동안 시간 초과 기간이 경과했습니다.
사전 로그인 핸드 셰이크가 실패했거나 서버가 제 시간에 응답하지 못했기 때문일 수 있습니다.
이 서버에 연결을 시도하는 동안 소요 된 시간은 다음과 같습니다.-[사전 로그인] 초기화 = 42030; handshake = 0;
.NET 애플리케이션은 다음 코드를 실행하는 작은 테스트 앱입니다.
using (SqlConnection conn = new SqlConnection(cs))
using (SqlCommand cmd = new SqlCommand("SELECT COUNT(*) FROM TheTable", conn))
{
conn.Open();
int rowCount = (int)cmd.ExecuteScalar();
}
TheTable 은 작고 78 행입니다.
그러나 .NET 응용 프로그램이이 오류를 수신 하는 동일한 컴퓨터 에서 SSMS 및 연결 문자열에 명명 된 사용자 ID / 암호를 사용하여 THESERVER에 연결할 수 있습니다.
ADO.Net 앱에서 연결이 실패하지만 SSMS의 동일한 자격 증명으로 성공하는 이유는 무엇입니까?
TCP / IP는 IPv4 주소에 대해 활성화되었지만 IPv6 주소에는 활성화되지 않았습니다 THESERVER
.
분명히 일부 연결 시도는 IPv4를 사용하고 다른 시도는 IPv6를 사용했습니다.
두 IP 버전 모두에 대해 TCP / IP를 활성화하면 문제가 해결되었습니다.
SSMS가 작동했다는 사실은 우연의 일치로 판명되었습니다 (처음 몇 번의 시도는 아마도 IPv4를 사용했을 것입니다). 나중에 SSMS를 통해 연결을 시도하면 동일한 오류 메시지가 나타납니다.
추가 IP 주소에 대해 TCP / IP를 활성화하려면 :
- SQL Server 구성 관리자 시작
- 노드 SQL Server 네트워크 구성을 엽니 다.
- MYSQLINSTANCE에 대한 왼쪽 클릭 프로토콜
- 오른쪽 창에서 TCP / IP를 마우스 오른쪽 단추로 클릭합니다.
- 속성을 클릭하십시오.
- IP 주소 탭을 선택합니다.
- 나열된 각 IP 주소에 대해 활성 및 사용이 모두 예인지 확인합니다.
Ive는 최신 Microsoft 업데이트 (2016 년 9 월 2 일)와 의심스럽게 일치하는 동일한 오류가 발생했습니다. 내 ASP.NET 응용 프로그램이 "사전 로그인 핸드 셰이크 승인을 사용하는 동안 시간 초과 기간이 경과했습니다"오류를 반환하는 동안 SSMS가 문제없이 연결되었음을 발견했습니다.
나를위한 해결책은 연결 문자열에 30 초의 연결 시간 제한을 추가하는 것이 었습니다. 예 :
ConnectionString="Data Source=xyz;Initial Catalog=xyz;Integrated Security=True;Connection Timeout=30;"
내 상황에서 유일한 영향을받는 연결은 통합 보안을 사용하는 연결이었고 연결하기 전에 사용자를 가장하고 있었지만 SQL 인증을 사용하여 동일한 서버에 대한 다른 연결이 제대로 작동했습니다!
2 개의 테스트 시스템 (별도의 클라이언트 및 SQL 서버)이 동시에 영향을 받아 Microsoft 업데이트가 의심됩니다!
Eric과 같은 문제를 해결했지만 다른 변경 사항이 있습니다.
- SQL Server 구성 관리자 시작
- 노드 SQL Server 네트워크 구성을 엽니 다.
- MYSQLINSTANCE에 대한 왼쪽 클릭 프로토콜
- 오른쪽 창에서 TCP / IP를 마우스 오른쪽 단추로 클릭합니다.
- 속성을 클릭하십시오.
- IP 주소 탭을 선택합니다.
- 나열된 각 IP 주소에 대해 활성 및 사용이 모두 예인지 확인합니다.
과
- 나열된 각 IP 주소에 대해 TCP 동적 포트가 비어 있고 TCP 포트 = 1433 (또는 다른 포트)인지 확인합니다.
- Windows 방화벽을 열고 포트가 들어오는 연결에서 열려 있는지 확인하십시오.
I had the same problem, trying to connect to a server in a local network (through VPN) from Visual Studio, while setting up an Entity Data Model.
Managed to solve only by setting TransparentNetworkIPResolution=false
in the connection string. In VS Add Connection Wizard, you can find it in the Advanced tab.
I had the same handshake issue when connection to a hosted server.
I opened my Network and sharing center and enabled IPv6 on my wireless network connection.
My executable that was built using .NET Framework 3.5 started reporting these connection issues in about half of the times after some Windows Updates got installed recently (week of Aug 7, 2017).
Connection failures were caused by .NET Framework 4.7 that got installed on target computer (Windows Updates auto-install was on) - https://support.microsoft.com/?kbid=3186539
Uninstalling .NET Framework 4.7 solved connection issues.
Apparently, there is a breaking change in .Net Framework 4.6.1 - TransparentNetworkIPResolution Updating connection string as per article also solved the issue without the need to roll back the framework version.
I fixed this error on Windows Server 2012 and SQL Server 2012 by enabling IPv6 and unblocking the inbound port 1433.
I had the same problem, manage to solve it by opening/enabling the port 1433 and tcp/ip in SQL Server Configuration Manager and then Restarted the Server
In my case above all options were already there.
Solved it by increasing Connection Time-out = 30.
Before you lose more time solving the problem, like me, try just to restart your windows machine. Worked for me after applying all the other solutions.
I had this problem when I did a SharePoint 2010 to 2013 migration. I suspected that because the database server is on the other side of a firewall which does not route IP6 that it was trying then to use IP6 and failing when connecting to the database.
I think the issue is now solved. The errors seem to have stopped. What I did was I simply disabled IP6 (by unchecking it) for the network adapter on the SharePoint Servers.
I had this same issue, but I was connecting to a remote db using a static IP address. So none of the above solutions solved my issue.
I had failed to add the proper User Mapping for the security Login I was using, so the solution for me was simply to ensure the User Mapping setting was set to access my database.
The "Connection Timeout expired" error commonly occurs in the following cases
- An instance of the SQL Server Database Engine is not running.
- The SQL Server Browser service is not running.
- The TCP/IP is disabled.
- The server name was typed incorrectly.
- There are network problems.
- The TCP/IP port for the Database Engine instance is blocked by a firewall.
- The client and server are not configured to use the same network protocol.
To check how to trace this error based on the above reasons check Connection Timeout Expired. The timeout period elapsed while attempting to consume the pre-login handshake acknowledgment
Solved this problem by blocking/ blacklisting IP address that were trying to brute force user accounts. Check your SQL access logs for large numbers of failed login attempts (usually for the 'sa' account).
For me, it turns out that the firewall in windows server was blocking the port 1433 which is the default sql server port. So adding an inbound rule to accept those connections made the trick for me.
In our case problem occured due to availability cluster configuration. To solve this issue we had to set MultiSubnetFailover
to True in the connection string.
More details on MSDN
In my case, the parameter Persist Security Info=true
with the user and password in connection string is causing the problem. Removing the parameter or set to false
solve the problem.
Try a simple SQL Server restart first before doing anything drastic. Might fix it. It did for me
참고URL : https://stackoverflow.com/questions/15488922/connection-to-sql-server-works-sometimes
'development' 카테고리의 다른 글
mongoDb에서 인덱스로 배열 요소를 제거하는 방법 (0) | 2020.09.05 |
---|---|
Start-Process로 표준 출력 및 오류 캡처 (0) | 2020.09.05 |
Spring의 양식 태그에서 modelAttribute와 commandName 속성의 차이점은 무엇입니까? (0) | 2020.09.05 |
명령 줄 인수를 사용하여 C #에서 PowerShell 스크립트 실행 (0) | 2020.09.05 |
C99 부울 데이터 유형? (0) | 2020.09.05 |