Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0038524Openbravo ERPA. Platformpublic2018-05-11 13:292018-08-08 13:06
alostale 
jarmendariz 
normalmajorhave not tried
closedfixed 
5
 
3.0PR18Q4 
alostale
Core
No
0038524: can't configure timeout for sending emails
It's not possible to configure any timeout for sending emails. In case the email server doesn't respond, it is possible to reach a situation where the thread sending the email is indefinitely stuck.
1. Configure a very slow smtp server
    You can use, ie., a fake smpt server like dumbster [1]
        
           SimpleSmtpServer.start(8025);
        

    and add breakpoints to simulate slowness

2. Configure Client in Openbravo to make use of it
3. Open a completed Sales Order
4. Click on send email
  -> Check the threads gets stuck while the email server is not responding:
"ajp-bio-127.0.0.1-8009-exec-678" daemon prio=10 tid=0x00007fd2800cf800 nid=0x1f7ff runnable [0x00007fd38befb000]
   java.lang.Thread.State: RUNNABLE
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:153)
    at java.net.SocketInputStream.read(SocketInputStream.java:122)
    at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:110)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
    - locked <0x00000001efd082a0> (a java.io.BufferedInputStream)
    at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:89)
    at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2131)
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1912)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
    at javax.mail.Service.connect(Service.java:317)
    - locked <0x00000001efd083f0> (a com.sun.mail.smtp.SMTPTransport)
    at javax.mail.Service.connect(Service.java:176)
    at javax.mail.Service.connect(Service.java:125)
    at org.openbravo.erpCommon.utility.poc.EmailManager.sendEmail(EmailManager.java:170)
    at org.openbravo.erpCommon.utility.reporting.printing.PrintController.sendDocumentEmail(PrintController.java:815)

---
[1] https://github.com/kirviq/dumbster [^]
* Make it possible to configure email to include timeouts
* Although JavaMail supports up to 3 different timeouts (timeout, connectiontimeout, writetimeout), I think this shouldn't be exposed to end user, a single timeout field should configure (with the same value?) all of them.
* Note current 1.4.4 JavaMail version, released in 2011, only supports connectiontimeout. We might need to upgrade to latest version to do a better support. Attached patch is tested with current latest version (1.6.1) and I found no issues, using gmail as smtp server.
No tags attached.
related to defect 0038567 closed alostale Openbravo ERP can get stuck sending emails 
related to defect 0038934 new Retail Retail Modules Emails are no longer sent via POS 
related to feature request 0040622 new Triage Platform Base Openbravo ERP Improve testing coverage on mail configuration 
causes defect 0039649 closed caristu Openbravo ERP Cannot send mail using EmailEventManager 
causes defect 0040603 closed jarmendariz Openbravo ERP NPE sending email if timeout not set 
diff 38524-WiP.diff (1,214) 2018-05-11 13:31
https://issues.openbravo.com/file_download.php?file_id=11793&type=bug
Issue History
2018-05-11 13:29alostaleNew Issue
2018-05-11 13:29alostaleAssigned To => platform
2018-05-11 13:29alostaleModules => Core
2018-05-11 13:29alostaleTriggers an Emergency Pack => No
2018-05-11 13:31alostaleFile Added: 38524-WiP.diff
2018-05-17 08:50alostaleStatusnew => acknowledged
2018-05-17 08:55alostaleIssue cloned0038567
2018-05-17 08:55alostaleRelationship addedrelated to 0038567
2018-05-17 16:06alostaleSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=17155#r17155
2018-06-21 16:26jarmendarizAssigned Toplatform => jarmendariz
2018-06-28 12:01jarmendarizStatusacknowledged => scheduled
2018-07-11 10:52jarmendarizReview Assigned To => alostale
2018-07-11 13:42hgbotCheckin
2018-07-11 13:42hgbotNote Added: 0105700
2018-07-11 13:42hgbotStatusscheduled => resolved
2018-07-11 13:42hgbotResolutionopen => fixed
2018-07-11 13:42hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/cf4416b527d97adba57b97484b66a33284101738 [^]
2018-07-11 13:43hgbotCheckin
2018-07-11 13:43hgbotNote Added: 0105701
2018-07-11 17:29jarmendarizNote Added: 0105703
2018-07-12 14:01jarmendarizRelationship addedrelated to 0038934
2018-07-12 14:01jarmendarizNote Added: 0105715
2018-07-13 11:42alostaleNote Added: 0105737
2018-07-13 11:42alostaleStatusresolved => closed
2018-07-13 11:42alostaleFixed in Version => 3.0PR18Q4
2018-08-08 13:06hudsonbotCheckin
2018-08-08 13:06hudsonbotNote Added: 0106211
2018-11-20 09:35aferrazRelationship addedcauses 0039649
2019-04-12 09:20alostaleRelationship addedcauses 0040603
2019-04-15 18:52jarmendarizRelationship addedrelated to 0040622

Notes
(0105700)
hgbot   
2018-07-11 13:42   
Repository: erp/devel/pi
Changeset: cf4416b527d97adba57b97484b66a33284101738
Author: Javier Armendáriz <javier.armendariz <at> openbravo.com>
Date: Mon Jun 25 09:27:44 2018 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/cf4416b527d97adba57b97484b66a33284101738 [^]

Fixed issue 38524: Cannot configure timeout for sending emails.

In order to fully support timeout for emails the following has been done:
- Updated javax.mail to the latest version to date (1.6.1), which includes
along with socket read timeout, connection and write timeout.
- Added a Smtp server timeout field in Smtp Server configuration tab which
defines the timeout that will be used in seconds.
- Improved EmailManager API by including a cleaner implementation of sendMail
method.

---
M legal/Licensing.txt
M src-db/database/model/tables/C_POC_CONFIGURATION.xml
M src-db/database/sourcedata/AD_COLUMN.xml
M src-db/database/sourcedata/AD_ELEMENT.xml
M src-db/database/sourcedata/AD_FIELD.xml
M src/org/openbravo/email/EmailEventManager.java
M src/org/openbravo/erpCommon/ad_process/AlertProcess.java
M src/org/openbravo/erpCommon/utility/poc/EmailManager.java
M src/org/openbravo/erpCommon/utility/reporting/printing/PrintController.java
A lib/runtime/javax.mail-1.6.1.jar
A src/org/openbravo/erpCommon/utility/poc/EmailInfo.java
R lib/runtime/mail-1.4.4.jar
---
(0105701)
hgbot   
2018-07-11 13:43   
Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: 7e3885eef8d0cae90beb0cb7dca2144213c5bf56
Author: Javier Armendáriz <javier.armendariz <at> openbravo.com>
Date: Wed Jul 11 10:54:21 2018 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/7e3885eef8d0cae90beb0cb7dca2144213c5bf56 [^]

Related to issue 38524: Can't configure timeout for sending emails.

sendMail method is marked as deprecated. This changeset adds a suppress warning
to the place that uses this method.

---
M src/org/openbravo/retail/posterminal/EmailSender.java
---
(0105703)
jarmendariz   
2018-07-11 17:29   
Updated SMTP Server configuration wiki page:
http://wiki.openbravo.com/wiki/Client#Email_Configuration [^]
(0105715)
jarmendariz   
2018-07-12 14:01   
Created manual test case in test link:
https://testlink.openbravo.com/testlink/linkto.php?tprojectPrefix=Communit&item=testcase&id=Communit-10929 [^]
(0105737)
alostale   
2018-07-13 11:42   
reviewed + tested
(0106211)
hudsonbot   
2018-08-08 13:06   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/bfd7a414183a [^]
Maturity status: Test