0

我正在开发与 PervasiveDB 交互的 ASP.NET MVC 应用程序,在单独的外部数据库服务器上运行。我使用带有连接字符串的 Pervasive ADO.NET 数据提供程序,例如:ServerDSN=dbname;UID=user;PWD=password;ServerName=87.xxx.xx.xxx; 在我的开发机器上,使用 IIS express 调试时一切都很好,但是当我在运行 IIS 7.0 的远程托管服务器上部署我的应用程序时,我在尝试连接数据库时遇到异常。

代码:

PsqlConnection conn = new PsqlConnection(ConnectionString);
conn.Open();
try
{
  PsqlCommand cmd = new PsqlCommand(query);
  cmd.Connection = conn;
  PsqlDataReader reader = cmd.ExecuteReader();
  while (reader.Read())
  {
    ...
  }
}
finally
{
  conn.Close();
}

例外:

2013-01-28 15:40:21.2574|ERROR|App.WebApiApplication|Pervasive.Data.SqlClient.PsqlException: 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 87.xxx.xx.xxx:1583 at Pervasive.Data.SqlClient.PsqlConnection.Open() at App.DBFacade.TestConnection() at App.WebApiApplication.Application_Start()

从托管服务器 ping 到数据库服务器正常。

我没有意识到我的开发环境和生产环境之间有什么区别,我该如何解决这个错误。

4

1 回答 1

0

此错误的原因是托管服务提供商阻止了给定 IP 和端口上的连接。

于 2013-01-29T13:54:55.197 回答