I am using postgreSQL in my application, But some times it throws NpgsqlException after a fixed interval of time.
我在我的应用程序中使用postgreSQL,但有时它会在固定的时间间隔后抛出NpgsqlException。
Below is the stack trace of the exception :
下面是异常的堆栈跟踪:
Exception message: Failed to establish a connection to 'server'.
at EntitySpaces.Interfaces.esDataProvider.esLoadDataTable(esDataRequest request, esProviderSignature sig)
at EntitySpaces.Interfaces.esDynamicQuery.Load()
at BusinessObjects.Users.ValidatePassword(String UserName, String Password) in e:\Code\Entities\Custom\Users.cs:line 50
at PassiveSTS.Login.Login_Authenticate(Object sender, AuthenticateEventArgs e) in e:\Code\STS\Login.aspx.cs:line 32
at System.Web.UI.WebControls.Login.AttemptLogin()
at System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Failed to establish a connection to 'server'.
at Npgsql.NpgsqlClosedState.Open(NpgsqlConnector context) in C:\Npgsql\NpgsqlClosedState.cs:line 171
Please help if anyone Knows, What i am doing wrong.
如果有人知道,请帮忙,我做错了什么。
Thanks in Advance.
提前致谢。
1 个解决方案
#1
1
Go to following folder, Program Files\PostgreSQL\9.4\data
转到以下文件夹,Program Files \ PostgreSQL \ 9.4 \ data
open the file 'pg_hba.conf' and addline in following section,
在下一节中打开文件'pg_hba.conf'和addline,
IPv4 local connections: host all all 100.10.1.00/24 md5
IPv4本地连接:主机全部为100.10.1.00/24 md5
where 100.10.1.00 is the server ip from which you are accessing postgres server.
其中100.10.1.00是您从中访问postgres服务器的服务器IP。
Otherwise you can Add following line,
否则你可以添加以下行,
host all all 0.0.0.0/0 md5
主持所有0.0.0.0/0 md5
that allow all ips to connect. Restart server and try.
允许所有ips连接。重启服务器并尝试。
Add following lines to 'postgresql.conf' file
将以下行添加到'postgresql.conf'文件中
listen_address = '*' port = 5432
listen_address ='*'port = 5432
#1
1
Go to following folder, Program Files\PostgreSQL\9.4\data
转到以下文件夹,Program Files \ PostgreSQL \ 9.4 \ data
open the file 'pg_hba.conf' and addline in following section,
在下一节中打开文件'pg_hba.conf'和addline,
IPv4 local connections: host all all 100.10.1.00/24 md5
IPv4本地连接:主机全部为100.10.1.00/24 md5
where 100.10.1.00 is the server ip from which you are accessing postgres server.
其中100.10.1.00是您从中访问postgres服务器的服务器IP。
Otherwise you can Add following line,
否则你可以添加以下行,
host all all 0.0.0.0/0 md5
主持所有0.0.0.0/0 md5
that allow all ips to connect. Restart server and try.
允许所有ips连接。重启服务器并尝试。
Add following lines to 'postgresql.conf' file
将以下行添加到'postgresql.conf'文件中
listen_address = '*' port = 5432
listen_address ='*'port = 5432