-
-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.testConnection() blocks indefinitely #189
Comments
I see that at https://github.com/bbottema/simple-java-mail it says "You can now test the connection to the SMTP server" in v5.1.0 with a link to #179, which seems completely unrelated to testing connections. But the test connection feature is present in v5.0.3, so I don't understand what this means. Did something related to testing connections change in v5.1.0 that might help here? |
Possibly related to #182? |
I agree, this is probably related. Are you able to get the timeout working with good old manual Session properties? |
I have not been able to reproduce the problem myself. I don't know what condition triggers the timeout being ignored. |
I've been able to reproduce this issue using a plain socket server that does not respond at all. I can verify that using the manual session properties works. Here is a test case to reproduce both ways: I think the problem is that MailSender#configureSessionWithTimeout is only ever called by #send but not by test connection. This leads to a session for connection tests without the timeouts. |
Ahh, I was not thinking of this as a problem specific to |
Started working on a fix... |
…as when sending an email, thereby adding the missing time-out properties when testing a connection
Fix released in 5.1.2, can you please verify, @sddavis, @bmuskalla? |
Excellent, thanks for the report and the work! |
A call to org.simplejavamail.mailer.Mailer.testConnection() with a session timeout of 60s blocked for 3 hours before the user gave up and killed the process. This was using SMTP on port 25 with simple-java-mail-5.0.3.jar.
Thread dump:
at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) at java.net.SocketInputStream.read(SocketInputStream.java:171) at java.net.SocketInputStream.read(SocketInputStream.java:141) at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:126) at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) at java.io.BufferedInputStream.read(BufferedInputStream.java:265) at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:104) at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2425) at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2172) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:726) at javax.mail.Service.connect(Service.java:388) at javax.mail.Service.connect(Service.java:246) at javax.mail.Service.connect(Service.java:195) at org.simplejavamail.mailer.internal.mailsender.MailSender.testConnection(MailSender.java:380) at org.simplejavamail.mailer.Mailer.testConnection(Mailer.java:222)
The text was updated successfully, but these errors were encountered: