Problem with connecting to email server (OD-700)
Artur opened 4 years ago

I have email account configured in Administration/Mail Settings. I am pretty sure it used to work a while ago, when I was setting it up a couple of months ago. It could be on version 4.x or 5.0.x. I am not sure.

I have recently upgraded it to 7.0.5. I do not know if this is related to the upgrade but now my 1dev installation cannot connect to my email server. I mean, it can connect. I can see on my email server logs that 1dev opens connection on port 587 for smtp and 993 for imap but after a while it disconnects with timeout. It seems like it does not even attempt to authenticate.

Here is how it looks like on the 1dev side:

Please wait...
Sending test mail to [email protected]...
java.lang.RuntimeException: org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.email.domain.com:587
    	at io.onedev.server.notification.DefaultMailManager.sendMail(DefaultMailManager.java:264)
    	at io.onedev.server.web.page.admin.mailsetting.MailSettingPage$2$3.call(MailSettingPage.java:138)
    	at io.onedev.server.web.page.admin.mailsetting.MailSettingPage$2$3.call(MailSettingPage.java:110)
    	at io.onedev.server.persistence.DefaultSessionManager.call(DefaultSessionManager.java:79)
    	at io.onedev.server.web.page.admin.mailsetting.MailSettingPage$2.runTask(MailSettingPage.java:110)
    	at io.onedev.server.web.component.taskbutton.TaskButton$2.call(TaskButton.java:173)
    	at io.onedev.server.web.component.taskbutton.TaskButton$2.call(TaskButton.java:144)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at io.onedev.server.security.SecurityUtils$1.run(SecurityUtils.java:352)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)
    Caused by: org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.just-4.email:587
    	at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1469)
    	at org.apache.commons.mail.Email.send(Email.java:1496)
    	at io.onedev.server.notification.DefaultMailManager.sendMail(DefaultMailManager.java:262)
    	... 11 more
    Caused by: javax.mail.MessagingException: Exception reading response;
      nested exception is:
    	java.net.SocketTimeoutException: Read timed out
    	at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2460)
    	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2187)
    	at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:740)
    	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 javax.mail.Transport.send0(Transport.java:254)
    	at javax.mail.Transport.send(Transport.java:124)
    	at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1459)
    	... 13 more
    Caused by: java.net.SocketTimeoutException: Read timed out
    	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:106)
    	at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2440)
    	... 21 more

On my email server I only get simple:

2022/04/28 07:15:18 [info] 12#12: *4304 client 10.0.77.47:47682 connected to 0.0.0.0:993
2022/04/28 07:15:18 [info] 14#14: *4305 client 10.0.77.47:58558 connected to 0.0.0.0:587
2022/04/28 07:16:18 [info] 14#14: *4305 client timed out (110: Operation timed out) while in auth state, client: 10.0.77.47, server: 0.0.0.0:587
  • Robin Shen commented 4 years ago

    It works fine at my side connecting either to gmail or office365. Please check timeout in mail setting. It should be normally set to 60 seconds or more.

  • Artur commented 4 years ago

    It used to work for me too. But it stopped. Everything else is working with my email server. Both 1dev and email server run on my local network. Any suggestions on how to diagnose the problem would be helpful.

    As pointed out above, 1dev can connect to the email server as I can see on the mail server that a connection is opened from 1dev. But for some reason it is stuck and no data is exchanged.

  • Robin Shen commented 4 years ago

    This sounds odd. Since you mentioned OneDev4 works, can you please run a copy of that version and test if it sill works? You may also run OneDev with Java 17 to see if it makes any difference.

  • Artur commented 4 years ago

    Thank you for responding.

    After some research I found out that there is some problem with communication between 1dev in docker container and email server running in docker compose on the same host. I did not want to spend all my day on investigating so I changed the network mode 1dev container was running under to make sure it can access all ports on the host server. It is working now.

    In any case, it does not seem to be any fault of 1dev, rather my configuration. I was expecting this from the beginning but could not find an effective way to debug it from within 1dev. However, the 1dev container contains curl which helped me track the connectivity issue.

  • Artur changed state to 'Closed' 4 years ago
    Previous Value Current Value
    Open
    Closed
  • Artur commented 4 years ago

    I have solved this and it was not a problem with 1dev anyway.

issue 1/1
Type
Question
Priority
Major
Assignee
Issue Votes (0)
Watchers (4)
Reference
OD-700
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover