# Message handler bug?

**URL:** <https://forum.inductiveautomation.com/t/message-handler-bug/103225>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [March 4, 2025, 5:50pm UTC](https://forum.inductiveautomation.com/t/message-handler-bug/103225 "2025-03-04T17:50:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [March 4, 2025, 5:50pm UTC](https://forum.inductiveautomation.com/t/message-handler-bug/103225/1 "2025-03-04T17:50:32Z")

</div>

Either there is a small bug associated with a very specific combination of inheritance and message handlers, or I've missed some implementation details that causes unexpected (to me) errors.

Details:

- I have two projects, `Parent` and `Child`.
- `Child` inherits from `Parent`.
- `Child` has a gateway message handler called `zTestMessage`.
  - `zTestMessage` takes a payload value of `prop` and logs it to the gateway log using `system.util.getLogger('zTestMessage').info(str(payload['prop']))`

- `Parent` has a vision windows with a button that calls `zTestMessage`.
- `Child` inherits this window. The inherited vision window is opened in a session of `child` and the button is pushed.
- `zTestMessage` appears to run. The logs show up on the gateway webpage as expected.
- This error appears in the vision client diagnostic console.

```python
09:38:24.894 [AWT-EventQueue-0] ERROR com.inductiveautomation.factorypmi.application.script.ScriptMessageReceiver - Client script MessageHandlerException, message handler 'zTestMessage'
com.inductiveautomation.ignition.common.script.message.MessageHandlerException: The message handler "zTestMessage" could not be found! Check your event script message handlers.
	at com.inductiveautomation.ignition.common.script.message.MessageHandlerManager.processRequest(MessageHandlerManager.java:195)
	at com.inductiveautomation.ignition.common.script.message.MessageHandlerManager.processMessage(MessageHandlerManager.java:144)
	at com.inductiveautomation.factorypmi.application.script.ScriptMessageReceiver.receive(ScriptMessageReceiver.java:44)
	at com.inductiveautomation.ignition.client.gateway_interface.FilteredPushNotificationListener$1.run(FilteredPushNotificationListener.java:39)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

```

There's another project, `Daughter`.  
`Daughter` also inherits the vision window from `Parent`.  
When `Daughter` is opened in a vision client and the button pushed,

- Logging occurs as expected.
- No error is thrown in the vision client diagnostic logs.

There seems to be some quirky interaction between inheritance and message handling here, unless I'm missing something.

I admit that the setup itself is odd. I encountered this while developing a project. Eventually I expect there to be many `Daughter` projects using this message handler. I don't expect to actually launch `Child`, so I shouldn't actually see the issue once all of the projects are created. I was using `Child` to test the message handler before moving on and spent longer than I care to admit trying to figure out why `The message handler "zTestMessage" could not be found!`.

Ignition 8.1.17  
Support ticket: #140852

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [March 4, 2025, 6:00pm UTC](https://forum.inductiveautomation.com/t/message-handler-bug/103225/2 "2025-03-04T18:00:16Z")

</div>

Show your call to `system.util.sendMessage`. If you do not specify a scope (client, session or gateway) it will default to sending a message to all scopes if no user, role and host name are defined. That error is a result of no ~~gateway~~ client handler being present.

> **[system.util.sendMessage | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-util/system-util-sendMessage#parameters)**
>
> This function sends a message to clients running under the Gateway, or to a project within the Gateway itself.

Edit: now also my edit

---

<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:** [March 4, 2025, 6:02pm UTC](https://forum.inductiveautomation.com/t/message-handler-bug/103225/3 "2025-03-04T18:02:02Z")

</div>

> [@ryan.white](#):
>
> That error is a result of no ~~gateway~~ _client_ handler being present.

My edits.

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [March 4, 2025, 6:06pm UTC](https://forum.inductiveautomation.com/t/message-handler-bug/103225/4 "2025-03-04T18:06:51Z")

</div>

Adding a scope did fix it. I guess you learn something new every day. Thanks, all.

sendMessage call that works:  
`system.util.sendMessage('Child','zTestMessage',{'prop':1},'G')`

---

<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:** [March 4, 2025, 6:13pm UTC](https://forum.inductiveautomation.com/t/message-handler-bug/103225/5 "2025-03-04T18:13:54Z")

</div>

Ooo! Watch out!

Your `Parent` project is hard-coding the `Child` project name in that call. That both explains why you didn't get errors in the `Daughter` project. If the message handler `Child` can also handle messages from `Daughter`, then this isn't a problem.

But consider moving the code that the message handler runs into a project library script function in `Parent` and call it as a one-line from `Child`. Then set up the same handler in `Daughter`, and replace the hardcoded project in `sendMessage()` with `system.util.getProjectName()`. That makes your inheritable functionality overridable if ever needed.

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [March 4, 2025, 6:31pm UTC](https://forum.inductiveautomation.com/t/message-handler-bug/103225/6 "2025-03-04T18:31:30Z")

</div>

That's a good point. I did set it up so that the message handler in `Child` would handle messages from `Daugher`, `Daugher1`, ..., `DaugherN` to only have to setup one message handler. That does complicate overriding the logic in the future though.

It will be a good day when Gateway Event Scripts can be inherited individually instead of en-masse.
