简体   繁体   English

PostgreSQL服务器停止时,npgsql可以“监听”吗?

[英]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.

相关问题 使用丹麦字母时Postgresql / npgsql无法写 - Postgresql/npgsql cant write when useing danish letters Npgsql/Postgresql:“函数不存在”错误消息 - Npgsql/ Postgresql: “function does not exist” error message when it does Npgsql(PostgreSQL) 中的 LastInsertedId - LastInsertedId in Npgsql(PostgreSQL) PostgreSQL COPY IN和NPGSQL - PostgreSQL COPY IN and NPGSQL 音量更改事件-音量停止更改时监听 - Volume change event - listen when volume stopped changing 为Postgresql安装Npgsql.dll - Installing Npgsql.dll for Postgresql 无法使用 Npgsql 连接到 Postgresql 13 服务器,目标计算机主动拒绝连接 - Can't connect to Postgresql 13 server using Npgsql, destination computer actively deny connection EF Core 3.1,如何在带有 PostgreSQL (npgsql) 或除 SQL Server 之外的任何数据库上使用原始 sql - EF Core 3.1, how to use raw sql on a database with PostgreSQL (npgsql) or any other than SQL Server 尝试在 C# Winform 中查询 PostgreSQL 数据库时,ExecuteReader 出现 Npgsql.PostgresException 错误 - Npgsql.PostgresException error on ExecuteReader when attempting to query PostgreSQL database in C# Winform 搭建 Npgsql.EntityFrameworkCore.PostgreSQL 数据库时出现 System.IO.EndOfStreamException - System.IO.EndOfStreamException when scaffolding Npgsql.EntityFrameworkCore.PostgreSQL database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM