symfony2 logout after a period of inactivity - symfony

I got a Symfony2 (2.0.9) project and the B-Office part I do not understand where is set the idle time ?
identification generates a good session cookie "PHPSESSID" equal to the variable (config.yml) framework:session:lifetime:86400 (one day) BUT I'm automatically disconnected after an hour !

Did You check session lifetime on the server ? See the documentation for session.gc_maxlifetime. The default value is:
session.gc_maxlifetime = 1440
Which means 24 minutes.

Related

How can I prevent autologout of user in Symfony 4?

When the user uses my symfony application, then after a couple of minutes the user is automatically logged out, while he is working with the application. To prevent that I changed in
config/packages/framework.yaml
framework:
session:
cookie_lifetime: 86400
gc_maxlifetime: 1800
This means the cookie lifetime is set to 24 hours. So I expect the user will only be logged out when he closes the browser. But in reality he is still automatically logged out after half in hour or so. What other options can I try?
Did you try to unset gc_maxlifetime ? It seem that PHP clear the session after this time. Moreover it's 30 minutes lifetime like your logged out problem.
framework:
session:
cookie_lifetime: 86400
You should definitively don't set gc_probability to null otherwise PHP won't ever clean your "dead" session and your server will be lack of disk space after a time.
Also it can be worth it to have a look to your php.ini configuration values because PHP will take them if they aren't specifid in Symfony configuration.
In other words Symfony override your PHP configuration if you specify somes configurations (there is a list of them )

Symfony: logout automatically in a very short period of time

Whenever a user connect to the application after a very short period of time (like 2 or 3 minutes) he gets logged out from the application.
I thought it's the session's lifetime that being very short so I have increased it in the config.yml file like this:
framework:
session:
cookie_lifetime: 7200
But still the same problem.
The application works fine on locahost but I face this when it's running remotely!
Is there anything I should be aware of to fix this issue?
Check your session.cookie_lifetime in the php.ini file of your remote server, I'm not sure but it may override the parameters in Symfony.
After you change it, don't forget to restart php so the change is taken into account.

.Exist doesn't wait as per the given timeout in UFT14

I am trying to play my QTP11 scripts in the UFT14 (trail) but for some reason .Exist doesn't wait for the given timeout. Rather it is waiting as per the Object sync timeout project settings if the object doesn't exist. Any reason why?
Like my project's object sync timeout is set at 60 seconds. And when I use something like If ErrorObject.Exist(10) Then ErrorObject.Close -- this should wait for 10 seconds only but rather UFT14 is waiting for full 60 seconds. Is it a bug or is there any extra setting which I have to apply in UFT14 for Exist to wait for the given timeout only?
Edit - On further inspection I found out that this is an issue with Java objects only. So might be a bug in Java addin. Can anyone verify or provide a workaround.
Edit - HP acknowledged that this is an issue. Here is the link if anyone is interested.
https://softwaresupport.hpe.com/group/softwaresupport/search-result/-/facetsearch/document/KM02764499
This is because of the default timeout in UFT.You can change that default timeout as below
Test Settings -> Run -> Object synchronization timeout
Change the "Object synchronization timeout" in seconds.
Or You can do this directly through vbscript code
Setting("DefaultTimeout") = 5000(This value is in milliseconds)

How to restrart asp.net session start time on server?

My Server (VPS) takes a DateTime about 12 hours more than now DateTime, after a system restart.(tomorrow date and toggled AM/PM time).
The issue is that when I correct the date and the time on server, I can not login to my asp application anymore! In fact the login proccess goes well but it logs out immediately. It seems that the session start time is still tomorrow(the wrong DateTime) and the sliding expiration time always compares to the current server time and causes logout.
How can i restart session start time? Which service or configuration will restart it to take the correct DateTime?
it should not changed after restart, do you share this situation with your service provider?
it's better to work with UTC times.
Dim timeZone = TimeZoneInfo.FindSystemTimeZoneById("Central America Standard Time")
Dim utcNow As Date = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, timeZone)
when you change server time it will not effect your sessions. you must remove or renew your sessions.
if your problem just with sessions
Session.Clear()
Session.Abandon()
Session.RemoveAll()
also restarting application will do same thing.
you can restart your application these ways;
1
restart IIS
2
File.SetLastWriteTime(HttpContext.Current.Request.MapPath("~\Web.config"), Date.Now)
3
rename web.config file to something(like 0web.config) and after that rename it again to web.config
4
create app_offline.htm on your root folder. it will close your app. when you want go online again rename it something else like 0app_offline.htm

ASP.NET MVC why does my app keep restarting?

I have an ASP.NET MVC website that gets about 6500 hits a day, on a shared hosting platform at Server Intellect. I keep seeing app restarts in the logs and I cannot figure out why.
I've read Scott Gu's article here: http://weblogs.asp.net/scottgu/archive/2005/12/14/433194.aspx
and implemented the technique, and here's what shows up in my log:
Application Shutdown:
_shutDownMessage=HostingEnvironment initiated shutdown
HostingEnvironment caused shutdown
_shutDownStack=at
System.Environment.GetStackTrace(Exception e, Boolean needFileInfo) at
System.Environment.get_StackTrace() at
System.Web.Hosting.HostingEnvironment.InitiateShutdownInternal() at
System.Web.Hosting.HostingEnvironment.InitiateShutdown() at
System.Web.Hosting.PipelineRuntime.StopProcessing()
It seems to occur about every five minutes.
Are there any other ways to debug this?
UPDATE: Here are the application pool settings mentioned by Softion:
CPU
Limit : 0
Limit Action : no action
Limit Interval : 5 Minutes
Process Model
Idle Timeout : 20 Minutes
Ping Maximum Response Time : 90 Seconds
Startup Time Limit : 90 Seconds
Rapid-Fail Protection
Enabled : True
Failure Interval : 5 Minutes
Recycling
Private Memory Limit : 100 MB
Regular Time Interval : 1740 Minutes (29 Hours)
Request Limit : 0
Specific Times : none
Virtual Memory Limit : 0
You can easily grab the reason of the shutdown by HostingEnvironment.
You read Scott Gu article, but you missed its comments.
var shutdownReason = HostingEnvironment.ShutdownReason;
If the reason is HostingEnvironment, check the IIS application pool parameters controlling recycling. I've put a red dot near each one. Check the description in the bottom help box in your own copy for full info.
You can ask your provider to give you the applicationHost.config file where all these parameters are set. They find it in C:\Windows\System32\inetsrv\config. I'm sure you can also get them using some .NET api.
For 6500 hits a day, which is a very low hit rate, i'm betting the "Idle time-out" is set to 5mn.
Update (moved comments to here //jgauffin)
CPU Limit 0 = disabled.
Process Model Idle Timeout : 20 Minutes (20mn without a request recycles your app).
Rapid-Fail Protection enabled (5mn). You need to know the maximum failures count. If your app throws more than this exception count in 5mn it will we recycled.
Private Memory Limit : 100 MB. Yes you should profile, this is a low limit.
Regular Time Interval : 1740 Minutes (29 Hours): it will recycle every 29h.
Request Limit : 0 (disabled).
Virtual Memory Limit : 0 (disabled).
Rapid-Fail Protection enabled (5mn). You need the maximum failures count. If your app throws more than this exception count in 5mn it recycles. If it recycles every 5mn this should be the thing to check. There should be 0 unhandled exception in secondary worker threads. Wrap your code into a try catch there.
re update:
The settings asked to the provider help, but is way better to ask for information on the reason of the restarts like I mentioned on my original answer i.e. the actual log entries of the restarts like I mentioned on my orig answer. From those you can know specifically what was triggered, I've seen happen one hitting different limits.
You really have to:
profile your application with a
realistic amount of test data
My money is on hitting resource limits set by your hosting provider.
Before going crazy with optimization without a target, contact your provider and ask them to give you information on the restarts.
Typical recycles:
idle x amount of time / like 15 mins
more than x amount of memory / like 200 MB
more than x % processor over y time / like 70 over 1 minute
a daily recycle
Once you know the case, you have to find out what's taking those resources. For this you have to profile your application with a realistic amount of test data. Knowing if it is memory or processor can help on knowing what to look for.
Is IIS set to recycle the app pool frequently?
Is there some kind of runaway memory leak in the app pool?
It requires a bit of know how on what your app does here's a list of things that can cause the app to restart/reset or even shut down
StackOverflowException
OutOfMemoryException
Any unhandled exception that crashes a thread
CodeContracts use Environment.FailFast when a contract violation occurs
Exceptions are quite easy to track if you can reproduce the issue with a debugger attached you can go into Visual Studio and enable all exceptions when they are thrown not caught by user code. It will sometimes reveal intresting stuff that otherwise is hidden away.

Resources