简体   繁体   中英

Could npgsql “listen” when postgresql server stopped?

I'm looking for 2 days now. I'm using the listen/notify with SyncNotification=true It works fine. But what if someone need to restart the postgresql server? 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#?

You can try the Keepalive parameter on connection string, documentation explains:

Keepalive : The number of seconds of connection inactivity before Npgsql sends a keepalive query.

Reference: http://www.npgsql.org/doc/connection-string-parameters.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM