This failure occured while attempting to connect to the Principle server One of our clients recently came to us with a problem he's facing while working with our application. The error in the log file is the next:


  System.Data.SqlClient.SqlException (0x80131904): Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.  This failure occured while attempting to connect to the Principle server.
  System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out


As far as I know, that client has set up mirroring between two database servers and he's currently working on the fail-over server (They do that on purpose each now and then).

I am aware that I could use the CommandTimeout property in my code to increase the time before a timeout is reached. 

The application is working normally, so it's connecting to the database way before this error happens. Also, connecting through SSMS is working.

Note that, due to security reasons on my client-side, I can't use a profiler to narrow down the problem to a specific query or procedure.

What I am actually concerned about is the error message in bold. 

Does that error mean that the actual problem is a connection problem between the Main DB Server and the Fail-Over server or could it also be triggered by a query taking more than the default 30 seconds?
You mention two key things in your post:


Mirroring
Work is being performed against the failover-server


I suspect what is going on is actually expected behavior.  Mirroring connection strings define both a Server (e.g. the Principal Server) and a Failover_Partner (e.g. the Mirror Server).  When establishing a connection to a mirrored database, if a connection to the Principal Server cannot be attained, an attempt to connect to the Mirror Server is then performed.

Per Connect Clients to a Database Mirroring Session (SQL Server):


  If a connection attempt fails or the retry time expires before it succeeds, the data access provider tries the other partner. If a connection is not opened by this point, the provider alternately tries the initial and failover partner names, until a connection is opened or the login period times out.


What I suspect the error is showing is the failed attempt to connect to the Principal Server because the database is actually active on the Mirror Server.  The error is thrown to your logs and then a successful connection is established against the Mirror Server because that's where the database is open/active.

This is expected behavior in a mirror configuration, and if you're able to (eventually) connect to the database, that means mirroring is working.  Take note that once you failover the database back to the Principal server, this error should no longer occur because the initial connection attempt to the Principal Server will once again succeed.