ConnectionTimeout not working

血红的双手。 提交于 2019-12-10 16:59:53

问题


I try to build a database failover (ASP classic) but I have problem with the setting: ConnectionTimeout. I set it to 1 second but still the server try to connect to the first connection for more then 20 second. I like the connection will be lost after 1 second so I can transfer the user to the second connection right a way.

Thanks,

<%
DSN             = "Provider=SQLOLEDB; Data Source=62.62.62.62; Initial Catalog=150109;User Id=noa; Password=tfdh545h54h;"
DSN1                = "Provider=SQLOLEDB; Data Source=127.0.0.1; Initial Catalog=150109;User Id=noa; Password=tfdh545h54h;"

Set conn            = Server.CreateObject("ADODB.Connection")
conn.ConnectionTimeout = 1
conn.CommandTimeout = 1
Set rs              = Server.CreateObject("ADODB.RecordSet")
On Error Resume Next
    conn.Open DSN
    If Err.Number <> 0 Then
        conn.Open DSN1
    End If
On Error Goto 0
'--

sql ="SELECT TOP 10 *"
sql = sql & " FROM allDB"
rs.Open sql, conn
if (not rs.eof) and (not rs.bof) then
    groupARRAY = rs.GetRows
end if
rs.Close

'--
conn.Close
Set rs          = Nothing
Set conn        = Nothing
%>

回答1:


I find a all most similar question as your here its link. Please read it. A snippet of it is here.

'minimum' delay of 13 secs comes from the lower TCP/IP layers which retry any connection at least 3 times. This can only be modified in registry (TCP/IP protocol parameters)



来源:https://stackoverflow.com/questions/10465788/connectiontimeout-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!