We are seeing an “events” error in the log in ignition but we cannot find where the “Error publishing tag change event.” is coming from. What’s the best way to track down where an error is coming from we have tons of change events ha ha ha!
This sounds like a spot you should of used system.util.getLogger() with a try and except on your script. If your current error isn’t giving you any idea of where to look then you get to do some hunting to find it.
I personally do something like:
import traceback import sys try: Your code goes here except Exception, err: exc_type, exc_value, exc_tb = sys.exc_info() errtb = traceback.format_exception(exc_type, exc_value, exc_tb) errStr = str("My script did an error: "+str(err)+errtb + errtb) logger = system.util.getLogger("ScriptError") logger.info(errStr)
I thought that might be the case. I’m working on code cleanup right now. I can’t find this bugger though, but I’ll keep hunting.
@bpreston used your code you provided to create a generic logging function in the project. Thanks for that!
import traceback import sys def LogError(err, category): exc_type, exc_value, exc_tb = sys.exc_info() errtb = traceback.format_exception(exc_type, exc_value, exc_tb) errStr = str("My script did an error: " + str(err) + errtb + errtb) logger = system.util.getLogger(category) logger.info(errStr) #End LogError # Usage in event scripts try: some code of some sort... except Exception, err: EventScriptHelper.LogError(err, "ValueChanged")
So that helped narrow down where it’s coming from but it’s not actually the ValueChanged script. This is happening on a tag that is set to Fixed Rate execution every 30 seconds. It’s actually running my event script just fine, but it’s logging that error to the event log.
This construct will not catch java exceptions, only jython exceptions. You need two blocks:
I will go back and update all my scripts with the two however in the case of this issue that’s not catching this exception either.
It’s this guy here
And this is the valueChanged code as it stands.
The funny thing is, is that it’s working. Watch Mtl_Bin_Data fills Mtl_Bin_Json like it should every 30 seconds.
But also throws the events error every 30 seconds.
@pturmel I’ve only been capturing jython exceptions because I’m not as familiar with java so I haven’t used it in any of my scripts. For jython I can pull in the traceback info how I showed in my reply earlier. For java I’m not sure how I would return the same type of data. Any suggestions?
Please post the complete text of an exception. A screenshot just doesn’t have enough information. Use the code formatting button (This one: </> ) after pasting so it is readable and copyable.
This isn’t a bug in your tag change scripts.
It’s a bug in whatever 3rd party web socket module is appearing in that stack trace.
We wrote the websocket publisher. It writes to a mobile app and our ERP system. I have info debugging we built in enabled so I can see the activity on it, but that itself didn’t appear to be throwing exceptions. My initial thought was that might be the case too but the events exception isn’t happening on all of the PLCs only some.
The event code in both is identical (I know we should be using UDT we are working on converting)
It’s not about the tag change code you’ve written in Ignition.
That module has registered a tag change listener with the tag system and is throwing an exception while handling some tag change event.
OH MAN I looked all up and down that thing for some hit and I never saw that. We’ll take a look at what it’s not liking about that tag change. It looks like it’s not liking handling the json going into Mtl_Bin_Json.