2009-06-23 41 views
11

我們在我們的Web應用程序中隨機獲取此錯誤。爲什麼我會間歇性地得到這個錯誤? 「服務器未找到或無法訪問」

System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

這是有道理的,如果我們得到了錯誤的時間,但要斷斷續續地建議其他事情正在進行。

有沒有人遇到過這個? 任何建議或理論?

謝謝!

+1

這是否發生在SQL Server備份窗口? – 2009-06-23 14:42:27

回答

6

服務器可能太忙而無法響應 - 您是使用SQL Express還是Workgroup Edition?此外,此服務器一次有多少個連接?這個錯誤是否在特定時間發生在所有連接上,或者某些連接被拒絕而其他連接同時成功?

此外,如果您執行「PING -t Servername」並觀看它,每個ping是否會返回,或者有些丟失?這可能是網絡中斷的一個指標,可能會導致此錯誤。

4

我以前在訪問另一個位置的遠程服務器時見過這個。我懷疑這是由於兩個站點之間的路由器配置,因爲它是,我們應該說,cludgy。由於網絡配置或硬件損壞,你完全有可能得到它,但在你耗盡其他許多可能性之前,我不會跳到這個結論。

5

我們之所以這樣做,是因爲防火牆太多:遠離客戶端(比如HK或NY,我們在瑞士)發生的頻率越高。倫敦:很少。瑞士:從不。有人向我們解釋(通過我們的數據庫工程和MS幫助),由於路由器和防火牆的延遲,有時會擾亂Kerberos和/或相關時序。

修復:使用連接字符串中的端口。這樣可以避免往返於端口1434來枚舉實例。我們已經使用FQDN。

示例:server.domain.tld \實例,港口

當然YNNV,但它的工作對我們

4

我有完全相同的問題;我們也得到了這樣一句:

System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

這一個:

System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

第一個是特別奇怪的,因爲我們沒有使用命名管道。

無論如何,事實證明,問題是一個錯誤的開關。

我在應用程序和數據庫級別的故障排除之前搞砸了,然後將設置的任務設置爲在應用程序和數據庫之間來回PING(同時使用服務器的IP地址和NETBIOS名稱,以防問題出現netbios名稱查找)。

ping錯誤發生在數據庫錯誤的同時,因此我們知道這是網絡硬件,而不是更高級別的任何東西。

更換開關固定了一切。

相關問題