Skip to content
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

Closed
sddavis opened this issue Dec 12, 2018 · 10 comments
Closed

.testConnection() blocks indefinitely #189

sddavis opened this issue Dec 12, 2018 · 10 comments
Assignees
Milestone

Comments

@sddavis
Copy link

sddavis commented Dec 12, 2018

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)

@sddavis
Copy link
Author

sddavis commented Dec 12, 2018

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?

@sddavis
Copy link
Author

sddavis commented Dec 12, 2018

Possibly related to #182?

@bbottema
Copy link
Owner

Possibly related to #182?

I agree, this is probably related.

Are you able to get the timeout working with good old manual Session properties?

@sddavis
Copy link
Author

sddavis commented Dec 17, 2018

I have not been able to reproduce the problem myself. I don't know what condition triggers the timeout being ignored.

@bmuskalla
Copy link

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:
https://gist.github.com/bmuskalla/17d789716494d8ceb331bd02fb45c9dd

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.
Happy to provide a pull request with a fix if you can point me to the location where I can get the parent pom (maven-master-project) from.

@bbottema
Copy link
Owner

bbottema commented Jan 9, 2019

Ahh, I was not thinking of this as a problem specific to testConnection. Your assessment is probably correct, @bmuskalla. For this I would create a hotfix branch off of master to create a patch for this. The master is not yet modularized, so no parent POM needed there.

@bbottema bbottema self-assigned this Jan 9, 2019
@bbottema bbottema added this to the 5.1.2 milestone Jan 9, 2019
@bbottema
Copy link
Owner

bbottema commented Jan 9, 2019

Started working on a fix...

bbottema pushed a commit that referenced this issue Jan 9, 2019
…as when sending an email, thereby adding the missing time-out properties when testing a connection
@bbottema bbottema changed the title testConnection blocks indefinitely .testConnection blocks indefinitely Jan 9, 2019
@bbottema bbottema changed the title .testConnection blocks indefinitely .testConnection() blocks indefinitely Jan 9, 2019
@bbottema
Copy link
Owner

bbottema commented Jan 9, 2019

Fix released in 5.1.2, can you please verify, @sddavis, @bmuskalla?

@bbottema bbottema closed this as completed Jan 9, 2019
@bmuskalla
Copy link

Thanks @bbottema, works perfectly. I'm sure @sddavis is good as well, we've been working on the same defect :)

@bbottema
Copy link
Owner

Excellent, thanks for the report and the work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants