Page 1 of 1

Intermittent errors in ASP.NET application

Posted: Wed 03 Dec 2014 10:58
by stuey1978
Hi,

I hope you can help. We have a web application written in ASP.NET MVC 5 with Entity Framework 6 and using dotConnect for Postgres 2.3.293 (the latest version). The Postgres version on the server is as follows:

Code: Select all

PostgreSQL 9.2.9 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 4.7.2-5) 4.7.2, 64-bit
We are seeing intermittent connection issues in the event logs on the Windows servers. It is generally one of 2 errors:

Code: Select all

Exception information: 
    Exception type: PgSqlException 
    Exception message: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
   at Devart.Common.af.a(Byte[] A_0, Int32 A_1, Int32 A_2)
   at Devart.Common.l.c(Byte[] A_0, Int32 A_1, Int32 A_2)
   at Devart.Common.z.d(Byte[] A_0, Int32 A_1, Int32 A_2)

Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
   at Devart.Common.au.a(Byte[] A_0, Int32 A_1, Int32 A_2)
   at Devart.Common.z.d(Byte[] A_0, Int32 A_1, Int32 A_2)

An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
OR

Code: Select all

Exception information: 
    Exception type: PgSqlException 
    Exception message: The other side has sent a failure alert.
   at Devart.Data.PostgreSql.PgSqlDataReader.f(Int32 A_0)
   at Devart.Data.PostgreSql.PgSqlCommand.InternalExecute(CommandBehavior behavior, IDisposable stmt, Int32 startRecord, Int32 maxRecords)
   at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
   at Devart.Data.PostgreSql.Entity.t.a(CommandBehavior A_0)
   at Devart.Common.Entity.ab.b(CommandBehavior A_0)
   at Devart.Data.PostgreSql.Entity.t.b(CommandBehavior A_0)
   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)

The other side has sent a failure alert.
   at Devart.Common.af.a(Byte[] A_0, Int32 A_1, Int32 A_2)
   at Devart.Common.l.c(Byte[] A_0, Int32 A_1, Int32 A_2)
   at Devart.Common.z.d(Byte[] A_0, Int32 A_1, Int32 A_2)
I have tried various connection string settings but none of them seem to help. The current string is:

Code: Select all

Unicode=true;Ssl Mode=Require;Validate Connection=true;Keep Alive=30;
I have also created a test project to try and recreate the issue by opening a connection, running a simple select and closing the connection again, all on multiple threads. This results in SSL timed out errors every so often:

Code: Select all

2014-12-03 11:57:17 - An exception occurred:Error: The operation has timed out.
Stacktrace:    at Devart.Data.PostgreSql.v.y()
   at Devart.Data.PostgreSql.v..ctor(PgSqlConnectionOptions A_0)
   at Devart.Data.PostgreSql.b.a(u A_0, Object A_1, DbConnectionBase A_2)
   at Devart.Common.DbConnectionFactory.a(DbConnectionPool A_0, u A_1, DbConnectionBase A_2)
   at Devart.Common.DbConnectionPool.a(DbConnectionBase A_0)
   at Devart.Common.DbConnectionPool.GetObject(DbConnectionBase owningConnection)
   at Devart.Common.DbConnectionFactory.b(DbConnectionBase A_0)
   at Devart.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
   at Devart.Common.DbConnectionBase.Open()
   at Devart.Data.PostgreSql.PgSqlConnection.Open()
   at DevartConnectionTest.MainClass.<>c__DisplayClass3.<Main>b__1() in c:\Users\sbrown\Documents\DevartConnectionTest\Program.cs:line 39
Error: The operation has timed out.
Stacktrace:    at Devart.Security.SSL.x.d(IAsyncResult A_0)
   at Devart.Security.SSL.ah.b(IAsyncResult A_0)
   at Devart.Security.SSL.ah.a(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at Devart.Security.SSL.al.b(Byte[] A_0, Int32 A_1, Int32 A_2)
   at Devart.Common.af.b(Byte[] A_0, Int32 A_1, Int32 A_2)
   at Devart.Common.z.e(Byte[] A_0, Int32 A_1, Int32 A_2)
Which could just be due to there being too many open connections.

Do you know if there's a known issue with SSL connections in the Devart driver? Thanks!

Re: Intermittent errors in ASP.NET application

Posted: Wed 03 Dec 2014 12:10
by stuey1978
As an update to this - I have been playing around with a test program I made in .net. This program runs a simple SELECT against a new PgSqlConnection / Command (all enclosed in "using" blocks) and attempts to run this code in a for loop - creating a new Thread for each for loop iteration (so it doesn't wait for the command to finish) When comparing running a simple SELECT using a PgSqlConnection / Command I find that when the number of threads gets above 3 (the client machine has 4 CPUs if that makes any difference) I start getting SSL timeout errors every 15 seconds (default connection timeout).

When I use Npgsql instead I find that I don't get these timeouts.

Is this something that you guys can fix in the Devart driver? We're happy to use the Devart driver but if this is the cause of our issues then we might have to think about switching to Npgsql...

Re: Intermittent errors in ASP.NET application

Posted: Wed 03 Dec 2014 12:45
by stuey1978
Another update - I have tested my test program against our server machine and my local machine and I have found the following:

- If I switch SSL off (can only do this on my local machine) then there are no more connection errors

- With SSL switched on I find that the errors occur when the number of threads the program tries to use is equal to or greater than the number of CPUs in the system (2 on my local machine, 4 on the server machine)

Thanks

Re: Intermittent errors in ASP.NET application

Posted: Thu 04 Dec 2014 13:03
by MariiaI
I have also created a test project to try and recreate the issue by opening a connection, running a simple select and closing the connection again, all on multiple threads.

Could you please send us this test project, so that we are able to reproduce these issues in our environment and find the solution for you in a shortest time.

Re: Intermittent errors in ASP.NET application

Posted: Thu 04 Dec 2014 13:37
by stuey1978
I've sent the test project to the support email address - thanks for the quick response.

Re: Intermittent errors in ASP.NET application

Posted: Fri 05 Dec 2014 07:05
by MariiaI
stuey1978 wrote:I've sent the test project to the support email address - thanks for the quick response.
Unfortunately, we didn't receive response from you. Probably, your letter was blocked for some reason (i.e. the attachment, etc.).
Please re-send your letter again. Also, please send it to 'mariiaI at devart dot com'.
As an alternative, you can upload your project to some file exchange server and give us a download link.

Re: Intermittent errors in ASP.NET application

Posted: Mon 08 Dec 2014 11:09
by stuey1978
Hi - email sent, hopefully it gets through!

Re: Intermittent errors in ASP.NET application

Posted: Mon 08 Dec 2014 18:05
by Shalex
We have received your project but cannot reproduce the issue in our environment at the moment. We will ask you for an additional information by email.