Home > Blockchain >  How to set timeout value in NpgsqlConnection?
How to set timeout value in NpgsqlConnection?

Time:06-08

From Documentation: Docs

Connection string:"...;Timeout=1200";

Code:

public IDbConnection Connection
{
    get
    {
        return new NpgsqlConnection() { ConnectionString = this.config.GetConnectionString("PostgresConn") };
    }
}

...

    using (IDbConnection dbConnection = Connection)
    {                
        return dbConnection.ExecuteScalar<int>(query, new { OP = op }) > 0;
    }

Error message:

Couldn't set timeout (Parameter 'timeout')

CodePudding user response:

I get a more explicit error message specifying the timeout must be less than 1024

System.ArgumentException: Couldn't set timeout (Parameter 'timeout') ---> System.ArgumentOutOfRangeException: Timeout must be between 0 and 1024 (Parameter 'value')

and this is confirmed in the code here and here:

  • Related