将PostgreSQL服务器升级到版本13后,Npgsql无法再进行连接。这是一个.NET应用程序。通过命令行psql命令验证通信。我似乎不能从开发人员那里得到任何有用的错误来进一步调查。我确实让开发人员将Npgsql升级到版本5.0.1.1,但没有用。
任何关于调试的提示都将不胜感激!
ERROR 2020-12-16 16:02:44,499 333535ms Archive rieveUnlimitedData - Npgsql.NpgsqlException (0x80004005): Exception while reading from stream ---> System.TimeoutException: Timeout during reading attempt
at Npgsql.NpgsqlConnector.<<ReadMessage>g__ReadMessageLong|194_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.NpgsqlDataReader.<>c__DisplayClass41_0.<<ReadMessage>g__ReadMessageSequential|0>d.MoveNext()
使用psql进行测试:
C:\Program Files\PostgreSQL\13\bin>psql.exe -h XXX.XXXX.com -U postgres -d ais
Password for user postgres:
psql (13.1, server 13.0)
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.
ais=# \d
List of relations
Schema | Name | Type | Owner
----------+-------------------+----------+----------
public | geography_columns | view | postgres
这是我能得到的所有代码:
<add name="rawDB"
connectionString="server=host05.xxxxxx.local;port=5432;database=ais;uid=xxxxxxxxxxxx;password=xxxxxxxxxxx;timeout=30;commandtimeout=30" providerName="Npgsql"
/>
var connection = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["rawDB"].ConnectionString);
connection.Open();
var cmdSel = new NpgsqlCommand(queryText, connection);
发布于 2020-12-19 02:25:26
commandtimeout=0解决了这个问题。我怀疑在从PostgreSQL v9.x更改为PostgreSQL v13.x之后,身份验证时间的增加(SASL交换)会导致问题的发生。
https://stackoverflow.com/questions/65327943
复制相似问题