I have two Microsoft SQL 2005 databases setup in a fail over scenario. The application connection strings have the "Failover Partner" specified in the connection string.
When the currently live database fails over to the slave database, there is a small time period that a user can obtain a SqlClient.SqlException with the message "An existing connection was forcibly closed by the remote host".
Is this mainly due to the speed that the databases are failing over or is there something else that can be done to prevent these errors?
You're correct: it has to do with how long it takes the databases to fail over.
The synchronous mirroring failover timeline goes something like this:
No matter how fast your servers are, there's going to be a brief (at least a second) period when connections will bomb. Like Steven Lowe said, you have to trap that exception, wait, and try again. Keep in mind that it'll be more complex if your app issues several queries in a row as part of a larger transaction - your transaction might fail.