I'm using Dapper to query and get list of ID values from a table:
Dim systemIDs As IEnumerable(Of Long) = Nothing Dim connString As String = GetMyConnectionString() Using connection As New SqlConnection(connString) systemIDs = connection.Query(Of Long)("SELECT systemIDs FROM dbo.mySystems").ToList() End Using
The Query() call is giving an error:
"Connection Timeout Expired. The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement. This could be because the pre-login handshake failed or the server was unable to respond back in time. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=6; handshake=629;"
I googled this error but am not finding much related to Dapper about it. Any ideas? I thought the way I'm doing the query is correct, but am I missing something?
Note, when this error happens, if I resume then it seems to retry and connect fine. I only noticed this error because I'm breaking on exceptions while debugging. It is only happening on the first database connection, all other subsequent calls to .Query() are not doing the exception. I'm wondering what's going on with Dapper under the hood because I had been doing regular ADO.NET queries before I tried Dapper and I didn't notice this error then.
"This issue can be resolved by modifying the connection string to set the parameter â€˜TransparentNetworkIPResolutionâ€™ to false"
Dapper doesn't do anything remarkable here. I'm assuming your
connection here hasn't been opened yet - in which case dapper calls
Open() when it needs to, and presumably that is when it is erroring. But: the error itself has nothing whatsoever to do with dapper. It literally just calls
Open here (or
OpenAsync, if you're using the
async API). I strongly suspect you'd get exactly the same behavior if you move the
Open() into your own code.