# Message Handler issue when running from gateway event script

**URL:** <https://forum.inductiveautomation.com/t/message-handler-issue-when-running-from-gateway-event-script/109440>\
**Category:** Ignition\
**Tags:** perspective, ignition81\
**Created:** [August 6, 2025, 6:15pm UTC](https://forum.inductiveautomation.com/t/message-handler-issue-when-running-from-gateway-event-script/109440 "2025-08-06T18:15:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex.DeBate](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alex.debate/32/72299_2.png) [@Alex.DeBate](https://forum.inductiveautomation.com/u/Alex.DeBate)\
**Post date:** [August 6, 2025, 6:15pm UTC](https://forum.inductiveautomation.com/t/message-handler-issue-when-running-from-gateway-event-script/109440/1 "2025-08-06T18:15:44Z")

</div>

I have a sequence of two message handlers (one on the gateway events for the project) and one on a component in perspective. I've confirmed that the gateway message handler is triggered and runs succefully, but I get an error when it tries to execute the perspective-scoped message. This was working just yesterday, and with no apparent changes it has started throwing this error. Here is the Gateway Event Message Script:

```python
	#This message handler is triggered by the Forms.Forms.submitForm method in project "Forms".
	
	system.util.getLogger("Ignition Forms").debug("forms-submitted message handler recieved in project")
	messageHandler = "form-submitted-view"

	system.perspective.sendMessage(messageType=messageHandler, scope="session")

```

and here is the error from the gateway logs:

> com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 7, in handleMessage at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.getSession(AbstractScriptingFunctions.java:104) at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnSession(AbstractScriptingFunctions.java:118) at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.sendMessage(PerspectiveScriptingFunctions.java:745) at jdk.internal.reflect.GeneratedMethodAccessor893.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: No perspective session attached to this thread.

I'm unable to figure out how to account for the "No perspective session attached to this thread" error, and find it bizarre that this same script triggered the appropriate message handler on the component when I was testing it out yesterday.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 6, 2025, 6:22pm UTC](https://forum.inductiveautomation.com/t/message-handler-issue-when-running-from-gateway-event-script/109440/2 "2025-08-06T18:22:58Z")

</div>

I **guarantee** this wasn't working before as described.

Gateway events, such as gateway message handlers, have no concept of Perspective and cannot invoke `system.perspective` scripts without you explicitly passing a session/page/view ID in as arguments.

---

<div class="post-metadata">

**Author:** ![Alex.DeBate](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alex.debate/32/72299_2.png) [@Alex.DeBate](https://forum.inductiveautomation.com/u/Alex.DeBate)\
**Post date:** [August 6, 2025, 6:27pm UTC](https://forum.inductiveautomation.com/t/message-handler-issue-when-running-from-gateway-event-script/109440/3 "2025-08-06T18:27:06Z")

</div>

Somehow, this script was getting triggered and successfully distributing the form response to users as expected.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/3/a36bbd2b940fbbd430b00f023bf049a1fcbe097c.png)

I can't think of another route that would trigger this script **except** the function call for `system.perspective.sendMessage()` in the gateway even script.
