# How do I close all open Perspective sessions?

**URL:** <https://forum.inductiveautomation.com/t/how-do-i-close-all-open-perspective-sessions/52143>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 20, 2021, 5:46am UTC](https://forum.inductiveautomation.com/t/how-do-i-close-all-open-perspective-sessions/52143 "2021-10-20T05:46:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [October 20, 2021, 5:46am UTC](https://forum.inductiveautomation.com/t/how-do-i-close-all-open-perspective-sessions/52143/1 "2021-10-20T05:46:12Z")

</div>

I have a test gateway that only has 2 perspective sessions licensed. I’m at that limit because sessions have been opened and the browser closed in quick succession. I’m trying to force close them all so I can start a perspective session again, however i’m running into issues with the closeSession function.

I’m running this script to attempt to close all open sessions:

```auto
	import traceback
	try:
		sessions = system.perspective.getSessionInfo()
		for s in sessions:
			id = s['id']
			system.perspective.closeSession(sessionId=id)
	except:
		raise TypeError(traceback.format_exc())

```

but i’m getting the error below when calling the closeSession function:

```auto
java.lang.IllegalArgumentException: Invalid UUID string: 01213203

```

I’ve checked what fields I can get from getSessionInfo and sample data is below. There is only an Id field with an Id string, but there’s no UUID field that the closeSession function is looking for 😕

```auto
{
    "userAgent": "<designer>",
    "id": "01213203",
    "username": "REDACTED",
    "authorized": true,
    "project": "REDACTED",
    "uptime": 1193572,
    "clientAddress": "REDACTED (127.0.0.1)",
    "lastComm": 2,
    "sessionScope": "designer",
    "activePages": 2,
    "recentBytesSent": 162,
    "totalBytesSent": "619900",
    "pageIds": ["_Testing/View", "session-props"]
}

```

What do?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [October 20, 2021, 5:49am UTC](https://forum.inductiveautomation.com/t/how-do-i-close-all-open-perspective-sessions/52143/2 "2021-10-20T05:49:40Z")

</div>

Nevermind, I’m an idiot. You can’t close designer sessions.

```auto
	import traceback
	try:
		sessions = system.perspective.getSessionInfo()
		#raise TypeError(sessions[2])
		for s in sessions:
			if 'designer' not in s['userAgent']:
				id = s['id']
				system.perspective.closeSession(sessionId=id)
	except:
		raise TypeError(traceback.format_exc())

```

**It would be nice if you could call this function from Vision as well.**

---

<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:** [October 20, 2021, 12:40pm UTC](https://forum.inductiveautomation.com/t/how-do-i-close-all-open-perspective-sessions/52143/3 "2021-10-20T12:40:52Z")

</div>

> [@nminchin](#):
>
> It would be nice if you could call this function from Vision as well.

You can, via a gateway message handler....
