[Bug?] Message handler Error

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:

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

AzSiON message handler sends message to component:

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

Message handler on component:

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

On your util.sendMessage make it have a scope.

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

https://docs.inductiveautomation.com/display/DOC81/system.util.sendMessage

That might remove that error

2 Likes

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

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.

3 Likes