Describe the bug
When connecting to a server that does not respond to pre-login packets, connect() would hang indefinitely.
To Reproduce
func TestSqlserverConnectTimeout(t *testing.T) {
sd := sqlserver.Driver{}
cntor, cntorErr := sd.OpenConnector("sqlserver://128.199.74.51:8000")
if cntorErr != nil {
panic(cntorErr)
}
ctx, cancelTimeout := context.WithTimeout(context.Background(), 1*time.Second)
defer cancelTimeout()
_, connErr := cntor.Connect(ctx)
assert.ErrorContains(t, connErr, "timeout")
}
Expected behavior
The above test passes (connErr is a timeout error)
Further technical details
I found that it hangs in readPrelogin(), at r.BeginRead()