cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Tracking the behavior of the SMTP

SKannapiran
11-Garnet

Tracking the behavior of the SMTP

I've been utilizing a "Mail Server Thing" to send emails on a 24-hour schedule. Lately, I've encountered issues with some emails failing to send. It appears that the code lines are executing properly, but certain schedules aren't triggering, resulting in missed emails.

 

I'd appreciate assistance in tracking the behavior of the SMTP for each schedule. This way, I can log the activity in the ThingWorx log file for auditing purposes. Thank you in advance for your help.

5 REPLIES 5
Rocko
17-Peridot
(To:SKannapiran)

You can add logger.warn messages to the subscription of the ScheduledEvent. They will be in the log file then.

Thank you @Rocko, after adding that logger, I am able to see the below log captured in Application.log as "Error Executing Event Handler '<<SubscriptionName>>' for event Type.Thing:Entity.784:Event.ScheduledEvent". Can you please assist how to fix this issue?

Rocko
17-Peridot
(To:SKannapiran)

This means an exception is thrown and not caught by the code you put into the subscription. So check the code of the subscription or surround it with try/catch block and log the error in the catch block like this;

... } catch (err) {

let errMsg = "Thing [{}] Service [{}] error at line [{}] : {}";
logger.error(errMsg, me.name, err.fileName, err.lineNumber, err);

throw new Error(err); // throw original error message

}

This should give you more information about where the exception is thrown.

We already have catch block included, in that the above given errMsg also added. But it didn't capture because the event itself hasn't triggered. I have shared such failure instances for past couple of days which is captured in the TWX ApplicationLog.log file.

 

2024-03-20 18:45:00.023+0000 [L: ERROR] [O: c.t.s.s.e.EventInstance] [I: ] [U: ******] [S: ] [P: ] [T: TWEventProcessor-5] Error Executing Event Handler 'triggerMail' for event Type.Thing:Entity.795:Event.ScheduledEvent

2024-03-20 20:45:00.068+0000 [L: ERROR] [O: c.t.s.s.e.EventInstance] [I: ] [U: *******] [S: ] [P: ] [T: TWEventProcessor-4] Error Executing Event Handler 'triggerMail' for event Type.Thing:Entity.784:Event.ScheduledEvent
2024-03-20 20:45:00.068+0000 [L: ERROR] [O: c.t.s.s.e.EventInstance] [I: ] [U: ******] [S: ] [P: ] [T: TWEventProcessor-2] Error Executing Event Handler 'triggerMail' for event Type.Thing:Entity.785:Event.ScheduledEvent

2024-03-20 21:45:00.045+0000 [L: ERROR] [O: c.t.s.s.e.EventInstance] [I: ] [U: ********] [S: ] [P: ] [T: TWEventProcessor-16] Error Executing Event Handler 'triggerMail' for event Type.Thing:Entity.795:Event.ScheduledEvent
2024-03-20 21:45:00.060+0000 [L: ERROR] [O: c.t.s.s.e.EventInstance] [I: ] [U: ********] [S: ] [P: ] [T: TWEventProcessor-15] Error Executing Event Handler 'triggerMail' for event Type.Thing:Entity.785:Event.ScheduledEvent

2024-03-21 00:45:00.024+0000 [L: ERROR] [O: c.t.s.s.e.EventInstance] [I: ] [U: *******] [S: ] [P: ] [T: TWEventProcessor-15] Error Executing Event Handler 'triggerMail' for event Type.Thing:Entity.785:Event.ScheduledEvent

2024-03-21 20:45:00.056+0000 [L: ERROR] [O: c.t.s.s.e.EventInstance] [I: ] [U: ********] [S: ] [P: ] [T: TWEventProcessor-11] Error Executing Event Handler 'triggerMail' for event Type.Thing:Entity.784:Event.ScheduledEvent

2024-03-21 22:45:00.016+0000 [L: ERROR] [O: c.t.s.s.e.EventInstance] [I: ] [U: *******] [S: ] [P: ] [T: TWEventProcessor-14] Error Executing Event Handler 'triggerMail' for event Type.Thing:Entity.795:Event.ScheduledEvent

Rocko
17-Peridot
(To:SKannapiran)

Increase logging level to at least WARN, maybe you get more information. when those error occur.

Also, in LoggingSystem, Configuration Tab, switch on "Enable Stack Tracing" and "Enable Script Stack Tracing". Check for the Error Logs on disk, so in the ThingworxStorage/logs subdirectory. There are several error log files, which are not available in Composer/Monitor section. (ErrorLog.log, ScriptErrorLog.log)

Also note, that the event DID happen and trigger the subscription, otherwise you wouldn't have had the individual thing names in the log. So this part works.

Please also consider https://www.ptc.com/en/support/article/CS333561 and https://www.ptc.com/en/support/article/CS344383

 

Top Tags