سؤال

We have a 3 tier application developed using WCF. Our Web Layer [32 bit Windows 2003 Sp1] calls the WCF service [64 bit Windows 2008 R2 on an NLB] which communicates with the Oracle 10g DB [ 64 bit Linux ]. DB connection is established using Nhibernate 2.2. WCF communication uses BasicHTTPBinding.

In a 32 bit test environment application works well, but on the Live environment as specified above we experience crashes. As per the logging the repetitive error is,

System.ApplicationException :> Inner Exception being

NHibernate.ADOException: While preparing select stderrorme0_.ERR_NO as ERR1_10_, stderrorme0_.ERR_TYPE as ERR2_10_, .... ...., from STD_ERROR_MESSAGE stderrorme0_ where stderrorme0_.ERR_NO=:p0 an error occurred ---> System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.

this error repeats, only that the table being fetched changes.

Temporary Solution: Restarting the WCF service hosted in IIS.

Please help us with your suggestions and solutions to get this to work. This post is raised after so many trial and errors following various blogs.

هل كانت مفيدة؟

المحلول

This is almost certainly because of connections not being disposed of properly (https://stackoverflow.com/a/5442062/221708), which in your case may be caused by not disposing of NHibernate sessions properly. Just like you should wrap connections in using blocks, you should wrap NHibernate sessions in using blocks.

Here are a couple of good articles on managing NHibernate sessions in WCF:

Also remember that if you are using the sessionFactory.OpenSession(IDbConnection) overload, you are responsible for closing the connection returned by session.Close().

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top