Skip to main content
12-Amethyst
March 15, 2024
Question

Tracking the behavior of the SMTP

  • March 15, 2024
  • 1 reply
  • 1417 views

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.

1 reply

Rocko
19-Tanzanite
March 15, 2024

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

12-Amethyst
March 21, 2024

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
19-Tanzanite
March 21, 2024

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.