How do I set the timeout for ORMLite?
In my connection string I have added
Command Timeout=3000
as described here
but I am getting the below exception fairly quickly. I have also tried adding
Pooling=false
and upgraded to 5.2.0 but it looks like it is timing out at 30s.
This is exception
Npgsql.NpgsqlException
Exception while reading from stream
Npgsql.NpgsqlException (0x80004005): Exception while reading from stream ---> System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at Npgsql.ReadBuffer.Ensure(Int32 count, Boolean async, Boolean dontBreakOnTimeouts)
at Npgsql.ReadBuffer.Ensure(Int32 count, Boolean async, Boolean dontBreakOnTimeouts)
at Npgsql.NpgsqlConnector.DoReadMessage(Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isPrependedMessage)
at Npgsql.NpgsqlConnector.ReadMessage(Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications)
at Npgsql.NpgsqlConnector.ReadExpecting[T](Boolean async)
at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming)
at Npgsql.NpgsqlDataReader.NextResult()
at Npgsql.NpgsqlCommand.Execute(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteNonQuery(Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteNonQuery()
at ServiceStack.OrmLite.OrmLiteExecFilter.Exec[T](IDbConnection dbConn, Func`2 filter)
Any ideas what the issue is?
This Exception indicates a networking issue where it’s unable to establish a TCP connection which can happen as a result of firewalls, faulty network configuration or hardware or if your server is overloaded and is unable to respond to new TCP connection requests.
The link shows how you can configure PostgreSQL Npgsql ADO.NET Provider, you can also configure ADO.NET’s DbCommand.CommandTimeout with:
OrmLiteConfig.CommandTimeout = 120;
But this unlikely to solve your underlying issue.