# Error publishing tag change event. Where is it?!

**URL:** <https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [September 30, 2020, 6:11pm UTC](https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232 "2020-09-30T18:11:23Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![wci.jgiese](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wci.jgiese/32/50225_2.png) [@wci.jgiese](https://forum.inductiveautomation.com/u/wci.jgiese)\
**Post date:** [September 30, 2020, 6:11pm UTC](https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232/1 "2020-09-30T18:11:23Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [September 30, 2020, 6:39pm UTC](https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232/2 "2020-09-30T18:39:34Z")

</div>

This sounds like a spot you should of used [system.util.getLogger()](https://docs.inductiveautomation.com/display/DOC80/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:

```auto
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[1] + errtb[2])
	logger = system.util.getLogger("ScriptError")
	logger.info(errStr)

```

---

<div class="post-metadata">

**Author:** ![wci.jgiese](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wci.jgiese/32/50225_2.png) [@wci.jgiese](https://forum.inductiveautomation.com/u/wci.jgiese)\
**Post date:** [September 30, 2020, 6:41pm UTC](https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232/3 "2020-09-30T18:41:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wci.jgiese](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wci.jgiese/32/50225_2.png) [@wci.jgiese](https://forum.inductiveautomation.com/u/wci.jgiese)\
**Post date:** [September 30, 2020, 7:18pm UTC](https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232/4 "2020-09-30T19:18:44Z")

</div>

@bpreston used your code you provided to create a generic logging function in the project. Thanks for that!

```auto
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[1] + errtb[2])
	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")

```

---

<div class="post-metadata">

**Author:** ![wci.jgiese](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wci.jgiese/32/50225_2.png) [@wci.jgiese](https://forum.inductiveautomation.com/u/wci.jgiese)\
**Post date:** [September 30, 2020, 8:48pm UTC](https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232/5 "2020-09-30T20:48:51Z")

</div>

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.

---

<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:** [September 30, 2020, 10:29pm UTC](https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232/6 "2020-09-30T22:29:59Z")

</div>

> [@wci.jgiese](#):
>
> except Exception, err:

This construct will not catch java exceptions, only jython exceptions. You need two blocks:

> [@Catch IOException?](http://forum.inductiveautomation.com/t/catch-ioexception/18612/3):
>
> Consider using two except blocks, as jython’s standard Exception won’t catch pure java exceptions. Like so: import java.lang.Exception try: # something something something except Exception, e: # jython exception except java.lang.Exception, e: # java exception

---

<div class="post-metadata">

**Author:** ![wci.jgiese](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wci.jgiese/32/50225_2.png) [@wci.jgiese](https://forum.inductiveautomation.com/u/wci.jgiese)\
**Post date:** [October 1, 2020, 1:17pm UTC](https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232/7 "2020-10-01T13:17:23Z")

</div>

> [@pturmel](#):
>
> 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.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/5/554f4e93203d6df473ed985df02604b522108867.png)

It's this guy here

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/a/1a88a5763ee28b15b263339774d5dcfe07938700.png)

And this is the valueChanged code as it stands.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/b/9b560c3a22bcc58a30891306603afe0f4b3988e9.png)

---

<div class="post-metadata">

**Author:** ![wci.jgiese](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wci.jgiese/32/50225_2.png) [@wci.jgiese](https://forum.inductiveautomation.com/u/wci.jgiese)\
**Post date:** [October 1, 2020, 1:33pm UTC](https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232/8 "2020-10-01T13:33:13Z")

</div>

The funny thing is, is that it’s working. Watch Mtl\_Bin\_Data fills Mtl\_Bin\_Json like it should every 30 seconds.  
 ![GIF](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/b/9bf9884bc2ac4aa6eb7fe4189113005628cc8767.gif)

But also throws the events error every 30 seconds.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/7/6779c99bd9dd662efcdb10c2733fcf06e9604df0.png)

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [October 1, 2020, 2:07pm UTC](https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232/9 "2020-10-01T14:07:11Z")

</div>

@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?

---

<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:** [October 1, 2020, 2:08pm UTC](https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232/10 "2020-10-01T14:08:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 1, 2020, 2:08pm UTC](https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232/11 "2020-10-01T14:08:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wci.jgiese](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wci.jgiese/32/50225_2.png) [@wci.jgiese](https://forum.inductiveautomation.com/u/wci.jgiese)\
**Post date:** [October 1, 2020, 2:13pm UTC](https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232/12 "2020-10-01T14:13:12Z")

</div>

> [@Kevin.Herron](#):
>
> 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)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/b/cbb5d0ac2741c21fcce70212beb1747662f944a6.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 1, 2020, 2:16pm UTC](https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232/13 "2020-10-01T14:16:16Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/e/3e1dc879137c49ebba0cfffcb0432cd357bb2341.png)

---

<div class="post-metadata">

**Author:** ![wci.jgiese](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wci.jgiese/32/50225_2.png) [@wci.jgiese](https://forum.inductiveautomation.com/u/wci.jgiese)\
**Post date:** [October 1, 2020, 2:21pm UTC](https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232/14 "2020-10-01T14:21:19Z")

</div>

> [@Kevin.Herron](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![wci.jgiese](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wci.jgiese/32/50225_2.png) [@wci.jgiese](https://forum.inductiveautomation.com/u/wci.jgiese)\
**Post date:** [October 2, 2020, 7:14pm UTC](https://forum.inductiveautomation.com/t/error-publishing-tag-change-event-where-is-it/39232/15 "2020-10-02T19:14:16Z")

</div>

Exceptions handled better in that override in our websocket module now I’m set to fix the bug. Thanks all!

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/5/9579d7efb8eccf8f8ce42632e192eb084b9a5c27.png)
