Description
Hi, we started using this library for some weeks after upgrading to Java 20 and it is working fine so far (thanks), except for an error that happens a few times a day (normally between 2 and 5 times).
Our mailer configuration is:
Mailer mailer = MailerBuilder
.withSMTPServer(SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASSWORD)
.withSessionTimeout(60* 1000)
.withThreadPoolSize(20) // multi-threaded batch handling
.async()
.withConnectionPoolMaxSize(20)
.withConnectionPoolClaimTimeoutMillis(60 * 1000) // wait max 1 minute for available connection (default forever)
.withConnectionPoolExpireAfterMillis(30 * 1000) // keep connections spinning for 30 seconds (default 5 seconds)
.withProperties(getProperties())
.buildMailer();
With the properties:
private static Properties getProperties() {
Properties props = new Properties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.port", SMTP_PORT);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.ssl.enable", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.ssl.ciphersuites","SSL_RSA_WITH_RC4_128_MD5 SSL_RSA_WITH_RC4_128_SHA TLS_RSA_WITH_AES_128_CBC_SHA TLS_DHE_RSA_WITH_AES_128_CBC_SHA TLS_DHE_DSS_WITH_AES_128_CBC_SHA SSL_RSA_WITH_3DES_EDE_CBC_SHA SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA SSL_RSA_WITH_DES_CBC_SHA SSL_DHE_RSA_WITH_DES_CBC_SHA SSL_DHE_DSS_WITH_DES_CBC_SHA SSL_RSA_EXPORT_WITH_RC4_40_MD5 SSL_RSA_EXPORT_WITH_DES40_CBC_SHA SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA TLS_EMPTY_RENEGOTIATION_INFO_SCSV");
props.put("mail.smtp.connectiontimeout", "60000");
props.put("mail.smtp.timeout", "60000");
props.put("mail.smtp.writetimeout", "60000");
return props;
}
And the libraries versions:
implementation 'org.simplejavamail:simple-java-mail:8.6.2'
implementation 'org.simplejavamail:batch-module:8.6.2'
We sometimes, almost every day, see the error in the logs:
2024-06-11 06:29:32,162 ERROR [org.bbottema.genericobjectpool.GenericObjectPool] (pool-15-thread-1) error deallocating object already removed from the pool, ignoring it from now one...: org.simplejavamail.smtpconnectionpool.TransportHandlingException: error closing transport connection
at deployment.app.war//org.simplejavamail.smtpconnectionpool.TransportAllocator.deallocate(TransportAllocator.java:83)
at deployment.app.war//org.simplejavamail.smtpconnectionpool.TransportAllocator.deallocate(TransportAllocator.java:28)
at deployment.app.war//org.bbottema.genericobjectpool.GenericObjectPool$AutoAllocatorDeallocator.deallocate(GenericObjectPool.java:284)
at deployment.app.war//org.bbottema.genericobjectpool.GenericObjectPool$AutoAllocatorDeallocator.allocatedCorePoolAndDeallocateOneOrPlanDeallocations(GenericObjectPool.java:270)
at deployment.app.war//org.bbottema.genericobjectpool.GenericObjectPool$AutoAllocatorDeallocator.run(GenericObjectPool.java:256)
at java.base/java.lang.Thread.run(Thread.java:1623)
Caused by: jakarta.mail.MessagingException: Can't send command to SMTP host;
nested exception is:
java.net.SocketException: Connection or outbound has closed
at org.eclipse.angus.mail//org.eclipse.angus.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:2464)
at org.eclipse.angus.mail//org.eclipse.angus.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:2451)
at org.eclipse.angus.mail//org.eclipse.angus.mail.smtp.SMTPTransport.close(SMTPTransport.java:1399)
at deployment.app.war//org.simplejavamail.smtpconnectionpool.TransportAllocator.deallocate(TransportAllocator.java:81)
... 5 more
Caused by: java.net.SocketException: Connection or outbound has closed
at java.base/sun.security.ssl.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:1297)
at org.eclipse.angus.mail//org.eclipse.angus.mail.util.TraceOutputStream.write(TraceOutputStream.java:120)
at java.base/[java.io](http://java.io/).BufferedOutputStream.flushBuffer(BufferedOutputStream.java:125)
at java.base/[java.io](http://java.io/).BufferedOutputStream.implFlush(BufferedOutputStream.java:252)
at java.base/[java.io](http://java.io/).BufferedOutputStream.flush(BufferedOutputStream.java:240)
at org.eclipse.angus.mail//org.eclipse.angus.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:2462)
... 8 more
We can't even process those errors like we do for every other error log in our application because it doesn't happen when sending emails (Future<Void> future = mailer.sendMail(email); ... future.get()
), it happens in background, probably in some background process that manages the email connection pool, so we can't format the error the way we want to show in the logs.
We send about 100.000 to 200.000 emails per day (SES), and I see that this error is more common in periods with more emails sent at the same time (although it might be this way because the chance for triggering this error increases when sending more emails).
Any suggestions on how to fix it?