Message handler bug?

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.
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

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.

Edit: now also my edit

1 Like

My edits.

2 Likes

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')

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.

1 Like

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.

1 Like