[英]Could npgsql “listen” when postgresql server stopped?
I'm looking for 2 days now. 我现在正在寻找2天。 I'm using the listen/notify with SyncNotification=true It works fine. 我正在使用SyncNotification = true的监听/通知,它工作正常。 But what if someone need to restart the postgresql server? 但是,如果有人需要重新启动PostgreSQL服务器怎么办? The connection is lost, and the next "notify" will not be listened by the sync notification thread. 连接丢失,并且下一个“通知”将不会被同步通知线程监听。 :( How can I detect that the connection is lost, and relunch a connection on C#? :(如何检测连接丢失,并在C#上重新建立连接?
You can try the Keepalive parameter on connection string, documentation explains: 您可以在连接字符串上尝试Keepalive参数,文档说明:
Keepalive : The number of seconds of connection inactivity before Npgsql sends a keepalive query. Keepalive :Npgsql发送keepalive查询之前,连接不活动的秒数。
Reference: http://www.npgsql.org/doc/connection-string-parameters.html 参考: http : //www.npgsql.org/doc/connection-string-parameters.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.