# Perspective session connection closed unexpectedly

**URL:** <https://forum.inductiveautomation.com/t/perspective-session-connection-closed-unexpectedly/84397>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 17, 2024, 4:28pm UTC](https://forum.inductiveautomation.com/t/perspective-session-connection-closed-unexpectedly/84397 "2024-01-17T16:28:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Kuss](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Matthew\_Kuss](https://forum.inductiveautomation.com/u/Matthew_Kuss)\
**Post date:** [January 17, 2024, 4:28pm UTC](https://forum.inductiveautomation.com/t/perspective-session-connection-closed-unexpectedly/84397/1 "2024-01-17T16:28:51Z")

</div>

I have some clean-up that needs to occur when a session ends. If the user logs out this is a simple task. On tablets, sometimes the user just kills the application rather than logging out. Is there a way to trigger a Gateway script or session script to run when this occurs? When the operator does this, it generates a log in the event log, but I don't know how to run a script off of an specific error in the log.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 17, 2024, 4:45pm UTC](https://forum.inductiveautomation.com/t/perspective-session-connection-closed-unexpectedly/84397/2 "2024-01-17T16:45:54Z")

</div>

There is a session event for this, but note that it runs after a timeout, since browsers generally do not affirmatively close sessions.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [January 17, 2024, 6:34pm UTC](https://forum.inductiveautomation.com/t/perspective-session-connection-closed-unexpectedly/84397/3 "2024-01-17T18:34:47Z")

</div>

Yes, there are [Session Events](https://docs.inductiveautomation.com/display/DOC81/Perspective+Session+Event+Scripts#PerspectiveSessionEventScripts-StartupandShutdownEventScripts:~:text=Keystroke-,Startup%20and%20Shutdown%20Event%20Scripts,-Startup%C2%A0and%C2%A0), including the `Shutdown` Event. Note that a user logging out does not shut down the session, so be wary of logic dependent on a user logging out.

---

<div class="post-metadata">

**Author:** ![Matthew\_Kuss](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Matthew\_Kuss](https://forum.inductiveautomation.com/u/Matthew_Kuss)\
**Post date:** [January 18, 2024, 12:31pm UTC](https://forum.inductiveautomation.com/t/perspective-session-connection-closed-unexpectedly/84397/4 "2024-01-18T12:31:35Z")

</div>

Thanks that worked!

---

<div class="post-metadata">

**Author:** ![Matthew\_Kuss](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Matthew\_Kuss](https://forum.inductiveautomation.com/u/Matthew_Kuss)\
**Post date:** [March 27, 2024, 6:39pm UTC](https://forum.inductiveautomation.com/t/perspective-session-connection-closed-unexpectedly/84397/5 "2024-03-27T18:39:23Z")

</div>

A Shutdown Session event occurs for one of 6 reasons listed in the description of the event. Is there a way to determine which one of the six reasons are the source of the event?

Also, is there documentation anywhere for what is inside the session parameter? I suspect, if it's possible, the event reason inside that, but I'm not sure how to search/extract that information.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [March 27, 2024, 6:53pm UTC](https://forum.inductiveautomation.com/t/perspective-session-connection-closed-unexpectedly/84397/6 "2024-03-27T18:53:14Z")

</div>

This is a breakdown of everything the `session` object believes it has access to. It's a full-blown [session object](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/scripting-in-perspective/perspective-component-methods#session-objects).  
 ![Screenshot 2024-03-27 at 11.51.26 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/7/a7cd03dba775534d5d06f9ca99b3e651443efe93.png)

---

<div class="post-metadata">

**Author:** ![Matthew\_Kuss](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Matthew\_Kuss](https://forum.inductiveautomation.com/u/Matthew_Kuss)\
**Post date:** [March 27, 2024, 7:03pm UTC](https://forum.inductiveautomation.com/t/perspective-session-connection-closed-unexpectedly/84397/7 "2024-03-27T19:03:44Z")

</div>

Thanks cmallonee - I did see that, but wasn't able to find what I'm looking for. Are those items listed somewhere in detail online?

My main question is still, can I tell what/why the event was triggered?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [March 27, 2024, 7:57pm UTC](https://forum.inductiveautomation.com/t/perspective-session-connection-closed-unexpectedly/84397/8 "2024-03-27T19:57:07Z")

</div>

No, the Event does not provide any context as to why the session was shutdown, nor does the session itself have any idea why it is going through the shutdown process.

---

<div class="post-metadata">

**Author:** ![Matthew\_Kuss](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Matthew\_Kuss](https://forum.inductiveautomation.com/u/Matthew_Kuss)\
**Post date:** [March 28, 2024, 10:59am UTC](https://forum.inductiveautomation.com/t/perspective-session-connection-closed-unexpectedly/84397/9 "2024-03-28T10:59:41Z")

</div>

Roger that. Thank you
