Intermittent errors in ASP.NET application

Intermittent errors in ASP.NET application

Postby stuey1978 » Wed 03 Dec 2014 10:58

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!
stuey1978
 
Posts: 5
Joined: Wed 03 Dec 2014 10:30

Re: Intermittent errors in ASP.NET application

Postby stuey1978 » Wed 03 Dec 2014 12:10

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...
stuey1978
 
Posts: 5
Joined: Wed 03 Dec 2014 10:30

Re: Intermittent errors in ASP.NET application

Postby stuey1978 » Wed 03 Dec 2014 12:45

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
Last edited by stuey1978 on Thu 04 Dec 2014 13:37, edited 1 time in total.
stuey1978
 
Posts: 5
Joined: Wed 03 Dec 2014 10:30

Re: Intermittent errors in ASP.NET application

Postby MariiaI » Thu 04 Dec 2014 13:03

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.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Intermittent errors in ASP.NET application

Postby stuey1978 » Thu 04 Dec 2014 13:37

I've sent the test project to the support email address - thanks for the quick response.
stuey1978
 
Posts: 5
Joined: Wed 03 Dec 2014 10:30

Re: Intermittent errors in ASP.NET application

Postby MariiaI » Fri 05 Dec 2014 07:05

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.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Intermittent errors in ASP.NET application

Postby stuey1978 » Mon 08 Dec 2014 11:09

Hi - email sent, hopefully it gets through!
stuey1978
 
Posts: 5
Joined: Wed 03 Dec 2014 10:30

Re: Intermittent errors in ASP.NET application

Postby Shalex » Mon 08 Dec 2014 18:05

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.
Shalex
Devart Team
 
Posts: 7774
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for PostgreSQL