ERDDAP / erddap

ERDDAP is a scientific data server that gives users a simple, consistent way to download subsets of gridded and tabular scientific datasets in common file formats and make graphs and maps. ERDDAP is a Free and Open Source (Apache and Apache-like) Java Servlet from NOAA NMFS SWFSC Environmental Research Division (ERD).
Creative Commons Zero v1.0 Universal
78 stars 57 forks source link

ERDDAP_emailSmtpPort ignored #78

Closed aded closed 2 years ago

aded commented 2 years ago

Hello,

when I set SMTP port through env var, the value is ignored (587, Google account):

  ERDDAP_emailSmtpPort: "587"

log.txt:

Error: Sending email to XXX failed:
ERROR:

com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.googlemail.com, 25; timeout -1;
  nested exception is:
 java.net.ConnectException: Connection timed out (Connection timed out)
 at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2210)
 at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:722)
 at jakarta.mail.Service.connect(Service.java:342)
 at jakarta.mail.Service.connect(Service.java:222)
 at gov.noaa.pfel.coastwatch.util.SSR.sendEmail(SSR.java:1287)
 at gov.noaa.pfel.erddap.util.EDStatic.email(EDStatic.java:4346)
 at gov.noaa.pfel.erddap.util.EDStatic.email(EDStatic.java:4230)
 at gov.noaa.pfel.erddap.LoadDatasets.run(LoadDatasets.java:1176)
Caused by: java.net.ConnectException: Connection timed out (Connection timed out)
 at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:335)
 at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:214)
 at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2160)
 ... 7 more

If I set the value in setup.xml:

<emailSmtpPort>587</emailSmtpPort>

things work correctly.

Please note I deploy ERDDAP via-Docker. I opened an issue there (https://github.com/axiom-data-science/docker-erddap/issues/46), but the bug seems related to ERDDAP actually. The variable is properly set inside the container, I can see the value when the container starts, or through docker inspect. Or

$ sudo docker exec -it erddap printenv | grep ERDDAP_emailSmtpPort
ERDDAP_emailSmtpPort=587
BobSimons commented 2 years ago

I'm sorry for my delay in responding.

I looked in the code. I see the problem. For String parameters, ERDDAP is correctly looking for ERDDAP_paramName. But for int and boolean parameters, ERDDAP is incorrectly looking for just paramName.

So, for now as a work-around, try just setting "emailSmtpPort", not "ERDDAP_emailSmtpPort". And after the next ERDDAP release, switch to "ERDDAP_emailSmtpPort".

Thanks for reporting this bug.