SMTPSecureSocket in background

I have an application that is using SMTPSecureSocket to send e-mail via Gmail. All well and good. E-mail messages go out successfully. However, if the application is in the background, the e-mails eventually stop sending, and the SMTPSecureSocket gets stuck somewhere during the send process. No errors are produced. If I get the application to detect this, via a timeout timer, and start up a new socket, it also will not connect properly. If I bring the application to the foreground, everything starts working again.

Any ideas as to what might be happening?

macOS 10.12, Xojo 2017 r1.1


You can use declares or MBS Xojo Plugin classes, e.g. NSProcessInfoMBS.
There is a beginActivity method to declare the activity to the OS and avoid sleep.

Looks like App Nap is the culprit. Now to figure out how to disable it for this application.

see, but have a read through the whole thread as there is important additional information towards the end.