# Pruning Abandoned Sessions

**URL:** <https://forum.inductiveautomation.com/t/pruning-abandoned-sessions/2962>\
**Category:** Ignition\
**Created:** [May 24, 2011, 1:58pm UTC](https://forum.inductiveautomation.com/t/pruning-abandoned-sessions/2962 "2011-05-24T13:58:38Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 24, 2011, 1:58pm UTC](https://forum.inductiveautomation.com/t/pruning-abandoned-sessions/2962/1 "2011-05-24T13:58:38Z")

</div>

The link works great, but I was wondering if there was a way to automate it. Especially for Panel Edition installs that may lose power… hypothetically speaking… not that it ever happens around here… ![:mrgreen:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/d23659b203d2d24d394be983a52adb2fa6fe23d4.gif "Mr. Green")

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 28, 2011, 2:51am UTC](https://forum.inductiveautomation.com/t/pruning-abandoned-sessions/2962/2 "2011-05-28T02:51:45Z")

</div>

Tiny little bump…

OT: Have a great Memorial Day weekend with lots of time spent with family and friends and cooking things with fire… ![:mrgreen:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/d23659b203d2d24d394be983a52adb2fa6fe23d4.gif "Mr. Green")

---

<div class="post-metadata">

**Author:** ![Kevin.McClusky](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kevin.McClusky](https://forum.inductiveautomation.com/u/Kevin.McClusky)\
**Post date:** [May 31, 2011, 5:10am UTC](https://forum.inductiveautomation.com/t/pruning-abandoned-sessions/2962/3 "2011-05-31T05:10:20Z")

</div>

I’ve been playing with programming some modules, and I tried to do this using the Ignition Java API.

I was able to find the sessions, and figure out which ones were stale. However, I didn’t find anything in the API that allows me to terminate a session using Java.

In case I just missed something, here is the relevant code block.

`for (ClientReqSession session : context.getGatewaySessionManager().findSessions()) {
	long timeSinceLastAccess = ((System.currentTimeMillis()-session.getLastAccessedTime())/1000);
	logger.info("Session last accessed "+timeSinceLastAccess+" seconds ago.");
	if (timeSinceLastAccess > 10) {
		// Kill the session
	}
}`

If there is a way to do a session.kill(), I’d be happy to throw that in and package this up as a module.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 31, 2011, 6:47pm UTC](https://forum.inductiveautomation.com/t/pruning-abandoned-sessions/2962/4 "2011-05-31T18:47:39Z")

</div>

Thanks for taking a look at it, Kevin.

I’ve had zero time for API/module development myself. I hate it when work gets in the way of the fun stuff… 😆

---

<div class="post-metadata">

**Author:** ![Kevin.McClusky](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kevin.McClusky](https://forum.inductiveautomation.com/u/Kevin.McClusky)\
**Post date:** [May 31, 2011, 6:58pm UTC](https://forum.inductiveautomation.com/t/pruning-abandoned-sessions/2962/5 "2011-05-31T18:58:13Z")

</div>

It looks like my sessions actually have a Timeout value, that when it reaches that value, the session is automatically pruned.

[localhost:8088/main/web/status/sessions](http://localhost:8088/main/web/status/sessions)

(Running 7.2.6)

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 1, 2011, 12:26pm UTC](https://forum.inductiveautomation.com/t/pruning-abandoned-sessions/2962/6 "2011-06-01T12:26:03Z")

</div>

Well, yes. But, if we are only allowed 1 client session in panel edition and the client session isn’t flushed on startup from a power outage/flicker/flatulence, then I don’t really want to wait 10 minutes for it to automagically purge. I also have other machines that have to get back up and running, so I may not have time to manually purge them.

I haven’t (yet) found where the timeout setpoints are kept, but if I can get it down a lot lower, then I can get my timing in in better shape to recover.

On the flip side, I’ve noticed with panel edition that if it has an abandoned session, you can start a new one, and it works, but the autologon feature does not. Perhaps if that portion were looked at by IA, then the 10 minute limit may not be so bad.

---

<div class="post-metadata">

**Author:** ![Kevin.McClusky](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kevin.McClusky](https://forum.inductiveautomation.com/u/Kevin.McClusky)\
**Post date:** [June 3, 2011, 4:39am UTC](https://forum.inductiveautomation.com/t/pruning-abandoned-sessions/2962/7 "2011-06-03T04:39:47Z")

</div>

Hey IA guys, is there any way to kill a session using the Module SDK? (See code earlier in the thread…)

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [June 17, 2011, 10:37pm UTC](https://forum.inductiveautomation.com/t/pruning-abandoned-sessions/2962/8 "2011-06-17T22:37:24Z")

</div>

Probably, but we generally don’t respond to general improvement requests with “write a module to code around it”. (Hint: see GatewaySessionManager in the Gateway API)

Like Kevin said, client sessions are automatically pruned via the “timeout” mechanism. I think the real problem is that 10 minutes is way too long of a timeout, especially given than any live client will always ping the gateway every 2 seconds to make sure it’s still “connected”.

Maybe changing the timeout to 1 minute would be an effective fix.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 20, 2011, 4:54pm UTC](https://forum.inductiveautomation.com/t/pruning-abandoned-sessions/2962/9 "2011-06-20T16:54:05Z")

</div>

Still haven’t found out where this is set, but then, I’ve been off onto the the next crisis de jour.

Is that floating somewhere in the ignition.conf file?

EDIT: OK, maybe that wasn’t the right question to ask. I guess I’m asking “Is this something that’s user-configurable?”.

Sorry, still tired from Father’s Day. Who said this was supposed to be a relaxing day?!?

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [June 23, 2011, 10:17pm UTC](https://forum.inductiveautomation.com/t/pruning-abandoned-sessions/2962/10 "2011-06-23T22:17:29Z")

</div>

Yeah, sorry to lead you on like that. This is a change we’d have to make in the software. Actually, I did end up making this change for 7.2.7.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 27, 2011, 10:06am UTC](https://forum.inductiveautomation.com/t/pruning-abandoned-sessions/2962/11 "2011-06-27T10:06:19Z")

</div>

Ah. 😮 That would explain why I couldn’t find anything.

I’ll wait patiently.

Thanks, Carl. Your hero status has been restored.
