How do I close all open Perspective sessions?

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:

	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:

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 :confused:

{
    "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?

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

	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.

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

1 Like