This is a migrated thread and some comments may be shown as answers.

ORM WCF connection failing randomly

4 Answers 71 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bill
Top achievements
Rank 1
Bill asked on 10 Mar 2014, 03:56 PM
I have a Web Service used to send and receive data with phones. Using vs2013 and MSSQL. Using the default  ORM connection manager. I'm getting a random error about not being able to connect to the database. I have added debugging info to make sure I'm passing the correct server, user and password. I multiple databases and I build the connection string.
Below is a sample of how I connect:
using (msModel mgr=new msModel(connString)){...
I though it was too many connections made so I reduced the pool to 6 and idle connections to 3 - no help.
I have replaced username and password with XXX

Cannot open database "ms_gl4988a" requested by
the login. The login failed.

Login failed for user 'XXX'.
   at OpenAccessRuntime.ExceptionWrapper.Throw()
   at OpenAccessRuntime.storagemanager.StorageManagerFactoryBuilder.createSmfForURL()
   at OpenAccessRuntime.storagemanager.StorageManagerFactoryBuilder.createStorageManagerFactory()
   at OpenAccessRuntime.DataObjects.PersistenceManagerFactoryImp.createStorageManagerFactory()
   at OpenAccessRuntime.DataObjects.PersistenceManagerFactoryBase.init()
   at OpenAccessRuntime.DataObjects.PersistenceManagerFactoryImp.init()
   at OpenAccessRuntime.DataObjects.BootstrapPMF.getPersistenceManagerFactory(PropertySet
props)
   at OpenAccessRuntime.Helper.getPersistenceManagerFactory(PropertySet props)
   at OpenAccessRuntime.DatabaseAdapter.AssertPersistenceManagerFactory(String
usr, String password, Boolean open)
   at OpenAccessRuntime.DatabaseAdapter.GetObjectScope(TransactionProvider provider)
   at Telerik.OpenAccess.Database.GetObjectScope(TransactionProvider provider)
   at Telerik.OpenAccess.OpenAccessContextBase.GetScope()
   at Telerik.OpenAccess.OpenAccessContext.GetAllCore[T]()
   at Telerik.OpenAccess.OpenAccessContext.GetAll[T]()
   at Mainstreet.GlasAve9.Configuration.getConfigData(String ccode)
   at Mainstreet.GlasAve9.Configuration.IsConfigOn(String ccode)
   at Mainstreet.GlasAve9.PosMobile.PosMobile.putInvoice2(List`1 invoices, LoginInfo
loginInfo)

My connection:MultipleActiveResultSets=true;Pooling=false;Enlist=false;data
source=vmsql6\mainstreet9;initial catalog=ms_gl4988a;persist security
info=True;Integrated security=false;User
ID=XXX;password=XXX;multipleactiveresultsets=True;application
name=Mobile V2
Telerik.OpenAccess.Runtime...

TIA - Bill


4 Answers, 1 is accepted

Sort by
0
Ralph Waldenmaier
Telerik team
answered on 11 Mar 2014, 10:54 AM

Hi Bill,

Since you say you are getting this error randomly, may I ask if you are using database mirroring with your SqlServer?

We had a similar support case in the past where a customer was reporting exactly the same behaviour that the application was not able to log-in with the credentials specified. After a particular amount of time, everything worked again.



The reason in this case was the mirroring process of the database, where there was a synchronization between the primary and the secondary instance in process for a longer time and because of this efforts the primary server has stopped processing new connections.

In order to deal with such situations you probably can relax the mirroring setup and choose a mode that is more appropriate in your environment.



If I am wrong with my assumption of the mirroring setup, would you be able to provide us more information on the actual error? Is there something written in the event logs of the particular SqlServer? Any other event logs that could indicate an correlated errors?



I hope this information is helpful for you.

Do come back in case you need further assistance.





Regards,

Ralph Waldenmaier
Telerik
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.

0
Bill
Top achievements
Rank 1
answered on 11 Mar 2014, 12:20 PM
Not using and mirroring. I changed the default max connections used from 10 to 30 and I'm monitoring to see if that helps. Just to confirm, max connections used is per session, not a global setting, correct ? I noticed many connections are left open. Do you think I should shorten the IIS application pool timeout to less than 20 minutes ? The phone application connects every 15 minutes by default. Thanks
0
Ralph Waldenmaier
Telerik team
answered on 13 Mar 2014, 08:06 AM
Hi Bill,
The settings for your connection pool are per connection string. This is because for every unique connection string Telerik Data Access will create an internal database object that is responsible for operations against the database. It also maintains the connection pool and respects the settings specified. So if you have specified the maximum to be 30 it could of course be that you have up to 60 connections on your database if you application uses 2 different connection strings.

When you say many connections are left open. When do you observe this? In case the application is just running, then the minimum idle connections setting defines how many connections are at least open to your database. Was this the case?

When working with an IIS have you considered disposing the database object when the application is shut down or recycled? Please see this blog post for details how to do this. Does this help for your environment?
Unfortunately I can not give you an advise regarding the recycling period of the IIS.

Hope this helps.
Feel free to ask in case you have any other question.

Regards,
Ralph Waldenmaier
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
Bill
Top achievements
Rank 1
answered on 17 Mar 2014, 01:50 PM
It looks like I had a bug in my code when constructing the connection string which caused the connection to fail when going to some SQL servers. I'm still seeing connections left open in Microsoft SQL Activity manager. I'll implement the suggested code for application_end() to see if that helps.
Thanks
Tags
Data Access Free Edition
Asked by
Bill
Top achievements
Rank 1
Answers by
Ralph Waldenmaier
Telerik team
Bill
Top achievements
Rank 1
Share this question
or