# \[Bug?\] Message handler Error

**URL:** <https://forum.inductiveautomation.com/t/bug-message-handler-error/82828>\
**Category:** Ignition\
**Tags:** ignition81, perspective, scripting\
**Created:** [December 7, 2023, 8:17am UTC](https://forum.inductiveautomation.com/t/bug-message-handler-error/82828 "2023-12-07T08:17:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MSviga](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@MSviga](https://forum.inductiveautomation.com/u/MSviga)\
**Post date:** [December 7, 2023, 8:17am UTC](https://forum.inductiveautomation.com/t/bug-message-handler-error/82828/1 "2023-12-07T08:17:37Z")

</div>

Preface: This is on Ignition 8.1.32 Perspective.

I have been stumped by this for a while now, so im hoping someone might be able to give me a bit more insight into why this si happening. I have a group of 3 projects (named AzND, AzNN and AzSiON) that communicate by saving data into a database and then using `system.util.sendMessage()` to refresh query bindings on the other projects.

For example AzND saves data to the database and then sends a message to AzNN and AzSiON. The session message handlers then send a message using `system.perspective.sendMessage()` to the component to update its bindings using `self.refreshBinding()`.

This system works, the binding ARE being updated and new data is pulled from the database, however for some ungodly reason the gateway log seems to think no such message handlers exist:

`Gateway script MessageHandlerException, project 'AzND', message handler 'session refresh table': com.inductiveautomation.ignition.common.script.message.MessageHandlerException: The message handler "session refresh table" could not be found! Check your event script message handlers.`

I would appreciate if someone could point me in the right direction.

For clarification here is the exact code, though I dont think there is issue with the code at all.

AzND sends a message:

```auto
system.util.sendMessage("AzSiON", "session refresh table")

```

AzSiON message handler sends message to component:

```auto
def handleMessage(session, payload):
	system.perspective.sendMessage(messageType="Refresh Table", scope="session")

```

Message handler on component:

```auto
def onMessageReceived(self, payload):
	self.props.selection.selectedColumn = None
	self.props.selection.selectedRow = None
	self.refreshBinding("props.data")

```

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [December 7, 2023, 12:20pm UTC](https://forum.inductiveautomation.com/t/bug-message-handler-error/82828/2 "2023-12-07T12:20:42Z")

</div>

On your util.sendMessage make it have a scope.

```auto
system.util.sendMessage("AzSiON", "session refresh table",scope="S")

```

[https://docs.inductiveautomation.com/display/DOC81/system.util.sendMessage](https://docs.inductiveautomation.com/display/DOC81/system.util.sendMessage)

That might remove that error

---

<div class="post-metadata">

**Author:** ![MSviga](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@MSviga](https://forum.inductiveautomation.com/u/MSviga)\
**Post date:** [December 7, 2023, 12:41pm UTC](https://forum.inductiveautomation.com/t/bug-message-handler-error/82828/3 "2023-12-07T12:41:47Z")

</div>

Huh, that seems to have worked. Thanks. I wonder why it behaves like this though.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [December 7, 2023, 1:03pm UTC](https://forum.inductiveautomation.com/t/bug-message-handler-error/82828/4 "2023-12-07T13:03:35Z")

</div>

Well when you don't define a scope, and only have the project and message handler name, according to the manual, it sends out messages to Client, Gateway, and Session. You were picking up the Session one, however when it hit the gateway, you don't have a message defined there (you don't need it) and that is the error. So by narrowing down the scope for the message you are only hitting the Session defined message handler rather than all the others.
