I'm connecting to a remote sql server instance with the following connection string
"Network Library=DBMSSOCN;Data Source=xx.xxx.x.xxx,1433;Initial Catalog=MyDatabase;User Id=MyUserId;Password=MyPassword;Connect Timeout=120;"
- Sql Server Browser is running
- Local and remote connections are allowed using TCP/IP only
The application randomly fails to connect citing the following SqlException
TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Code to connect as follows
using (SqlConnection connection = new SqlConnection(m_ConnectionString))
{
connection.Open(); // falls over here
}
I thought about Firewall config on port 1433 but why would the Firewall sometimes permit connections and sometimes not?
Is Sql Server Agent required to be running? And if so why as the description of Sql Server Agent on MSDN is not obvious in this respect?
Thanks!
EDIT: Tried adding an explicit rule on the Firewall to open up 1433 and so far so good, but could be randomness again so hard to say if I fix or not yet