Vertx Mail connection error recovery issue

255 views
Skip to first unread message

Jojo Paderes

unread,
Sep 23, 2016, 12:59:53 AM9/23/16
to vert.x
I'm using Vertx Mail (http://vertx.io/docs/vertx-mail-client/java/) and so far it's a great and simple API for sending out email notifications. Everything works well as long as the connection with the SMTP is ok, but there seems to be a bug when the SMTP connection pool (default is 10 connections) is exhausted due to continuous connection errors with the SMTP server. 

The SMTP connection can't seem to recover and reconnect even after the SMTP server is up and running. After getting this debug log message (10 entries):

DEBUG i.v.ext.mail.impl.MailClientImpl    handleError
io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/127.0.0.1:3025
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:347)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:627)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:551)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:465)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:437)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:873)
at java.lang.Thread.run(Thread.java:745)


the following debug messages were logged repeatedly

DEBUG i.v.e.m.impl.SMTPConnectionPool     getConnection()
DEBUG i.v.e.m.impl.SMTPConnectionPool     waiting for a free socket
DEBUG i.v.e.m.impl.SMTPConnectionPool     getConnection()
DEBUG i.v.e.m.impl.SMTPConnectionPool     waiting for a free socket

Any suggestions on how to effectively deal with this issue?


Jojo Paderes

unread,
Sep 23, 2016, 1:01:06 AM9/23/16
to vert.x
I forgot to mention that I'm using the latest Vert.x version 3.3.3

Alexander Lehmann

unread,
Sep 23, 2016, 7:02:17 AM9/23/16
to vert.x
The pool should remove failed connections, if that doesn't work its probably a bug in the size counting

I will take a look tonight, I can't think of a workaround for that off the top of my head.

Alexander Lehmann

unread,
Sep 23, 2016, 2:58:26 PM9/23/16
to vert.x
You are right, that is a bug https://github.com/vert-x3/vertx-mail-client/issues/77

Other than creating and closing MailClient for each mail attempt, I don't think there is a workaround for this.

Jojo Paderes

unread,
Sep 25, 2016, 9:45:25 PM9/25/16
to vert.x
Thanks for confirming about this issue.

Alexander Lehmann

unread,
Sep 26, 2016, 12:49:06 PM9/26/16
to vert.x
I have written a unit test for it and fixed the issue over the weekend, if you are comfortable with using a branch version and compile it yourself, you try this:

https://github.com/vert-x3/vertx-mail-client/tree/issues/%2377-connection-refused
Reply all
Reply to author
Forward
0 new messages