What is the default time out of the storage Cache?

Topics: MMC SnapIn, NetSqlAzMan Core
Sep 25, 2013 at 3:32 PM
String connectionString = ConfigurationManager.ConnectionStrings["NetSqlAzMan"].ToString();
        IAzManStorage storage = new SqlAzManStorage(connectionString);
Coordinator
Sep 26, 2013 at 10:24 AM
Edited Sep 26, 2013 at 10:25 AM
Are you talking about the Cache timeout or the SQL Connection timeout ?

BTW, the first one is one hour and it is indicated in the NetSqlAzManCacheService.exe.config xml file (expirationValue parameter):
<?xml version="1.0"?>
<configuration>
  <configSections>
  </configSections>
  <connectionStrings>
    <add name="NetSqlAzMan.Cache.Service.Properties.Settings.NetSqlAzManStorageCacheConnectionString" connectionString="Data Source=(local);Initial Catalog=NetSqlAzManStorage;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <appSettings>
    <add key="expirationValue" value="0 1 0 0"/> <!-- days hours minutes seconds --> 
The second one is indicated in the connectionString parameter (connection timeout attribute) that if not indicated has a default value of 30 seconds.

Regards,
Andrea.
Sep 26, 2013 at 12:20 PM
Andrea - Thanks for your response -

I thought I had cancelled out - but here is the complete question -

String connectionString = ConfigurationManager.ConnectionStrings["NetSqlAzMan"].ToString();
        IAzManStorage storage = new SqlAzManStorage(connectionString);
       storage.StorageTimeOut = 14400; // TODO: For testing 60 x 60 x 4 ( 4 minutes was the time out)

Using the code above we found found that the time out was like 4 minutes. I am presuming that this is the Connection time from you description above. When I checked the default value it was 30 as you said (but not quite seconds if the above is right).

With this timeout we kept losing the permissions but once we removed this Timeout line - we were good.

Now again all of our Permissions are disappearing suddenly and they reappear after a few minutes - without even logging out and logging back on. Is there some explanation or things to look for with the problem we are having.

Regards,
Gita.
Sep 26, 2013 at 12:35 PM
  1. Also the NetAzman related web.config lines are as follows -

    <roleManager defaultProvider="NetSqlAzManRoleProvider" enabled="true" cacheRolesInCookie="false" cookieName=".ASPROLES" cookieTimeout="1440" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All">
            <providers>
                <clear/>
                <add name="NetSqlAzManRoleProvider" type="NetSqlAzMan.Providers.NetSqlAzManRoleProvider" connectionStringName="NetSqlAzMan" storeName="xxxx" applicationName="xxxxxx" userLookupType="DB" defaultDomain="" UseWCFCacheService="False"/>
            </providers>
        </roleManager>
    
But when we build the storage cache - Is the storage.StorageTimeOut equivalent to the Connection Timeout attribute that you indicated above ?? Its default was 30 when I checked and we have not set it currently.
  1. We don't have the Cache expiration value in the web.config that you indicated above -
<appSettings>
<add key="expirationValue" value="0 1 0 0"/> <!-- days hours minutes seconds --> 
  • Presume this is equivalent to storage.StorageTimeOut that we were trying to set in code.
Any suggestions to fix the permissions/Role time outs we are seeing will be helpful.
Coordinator
Sep 27, 2013 at 9:26 AM
Hello,
the property storage.StorageTimeOut is the equivalent of the IDBCommand.Timeout property and it is the timeout (evaluated in seconds, not in milliseconds) to execute a command on the SQL Server Storage; it has nothing to do with the duration of the cache, as erroneously I told you above (sorry, I confused).

About the "expirationValue" parameter you have to look in the NetSqlAzManCacheService.exe.config XML File and not in the web.config file.
(It's a parameter of the Windows service)

Let me know.
Regards,
Andrea.
Sep 27, 2013 at 1:08 PM
Edited Sep 27, 2013 at 1:16 PM
Andrea -

a. Thanks for the clarification - you did say the right thing but I misunderstood. We don't have NetSqlAzManCacheService.exe as a Windows Service. We have put all the above in our web.config. We initialize the NetAzman Storage Cache from our Web application directly.

So having it in the web.config should be fine I presume.

b. As far as the StorageCache Timeout - the IDBC command time out -
storage.StorageTimeOut = 14400; // TODO: For testing 60 x 60 x 4 ( 4 minutes was the time out)
It was very strange that at one time we had a permissions going away issue at roughly every 4 minutes - we were testing out different things and had the above line in our code. Removing this fixed it. If this caused it (14400 transforms to 4 minutes as per calculations above) could you explain this? Putting the line back caused the problem again. The calculation above didn't translate to seconds or msec (strangely). It very well could be an unrelated issue.


c. Right now our times between losing permissions are pretty random. Even doing the below-
<add key="expirationValue" value="0 4 0 0"/> <!-- days hours minutes seconds -->   ( 4 hours - is  not helping - definitely the cache is being rebuilt less frequently though)
Any other thoughts or answers is greatly appreciated. You have been a great help so far.

thanks,
gita.
Sep 27, 2013 at 1:15 PM
Edited Sep 27, 2013 at 1:16 PM
Andrea -

In the code we check the a variable in the Cache and if that becomes null then we rebuild the cache.
StorageCache _SCCacheAzman = null;

IAzManStorage storage = new SqlAzManStorage(connectionString);
_SCCacheAzman = new StorageCache(connectionString);
_SCCacheAzman.BuildStorageCache();
Is this the correct way to deal with the Cache going away???
Sep 27, 2013 at 8:24 PM
Andrea -

Hopefully final email before you respond -

1, Adding the expirationValue - we set to 4 hours (probably not appropriate) helped a single instance of our application work better. However if we logged in as another User with a different role on a different browser then the permissions messed up. Could you explain this?
  1. We probably had two problems there - one with the expirationValue left as default (which is fixed) and this other one. Can you think of anything to help us solve this problem.
thanks a lot.
gita.
Coordinator
Oct 1, 2013 at 8:51 AM
I'm sorry but I'm missing. :-)
Maybe we should start from the "original issue".
What is the problem you're having?
Oct 1, 2013 at 12:35 PM
Edited Oct 1, 2013 at 12:35 PM
I was going to respond to you today - We finally figured out our problem yesterday. We had a static variable for deciding the permission set to use and it was causing our issues.

As I had mentioned we had two problems -
  1. The cache timing out really fast - which you helped us fix with the expiration value.
  2. The permissions periodically becoming wrong - changing the static variable fixed it.
Thanks a billion for you quick responses and helping out here.
Coordinator
Oct 1, 2013 at 4:19 PM
Great.
You're welcome.
;-)