Tryton client hung up when trying to send PDF to email and open automatically the same report

150 views
Skip to first unread message

Fabián

unread,
Aug 4, 2016, 11:28:13 AM8/4/16
to try...@googlegroups.com
In a test environment, Tryton is configured for converting invoice reports to PDF.

This is the scenario:

- User create invoice
- When button "Pay" it's clicked, it sends automatically to the customer's email the invoice in PDF format.
- After is sending (in the same click in button "Pay"), automatically it is opened the PDF report for printing.
- Normally in server there is a temporary process [1] that disappears immediatly when both process (send PDF and open PDF) are done.
- Many times Tryton hang up. Seems as it happens in the process when convert ODT to PDF. In server I see there a lot of processes in background. I put a few of them [2]. When processes are hang up, it is no possible to pay any invoice because of the problem.

Changing the behavior for only send the PDF to email, there is not much hang ups, but the problem persist.

[1]
9125 ?        Sl     0:00 /usr/lib/libreoffice/program/soffice.bin --headless --invisible --nocrashreport --nodefault --nofirststartwizard --nologo --norestore --

[2]
9359 ?        Sl     0:00 /usr/lib/libreoffice/program/soffice.bin --headless --invisible --nocrashreport --nodefault --nofirststartwizard --nologo --norestore --accept=pipe,name=trytond;urp;StarOffice.ComponentContext
9686 ?        Sl     0:00 /usr/lib/libreoffice/program/soffice.bin --headless --invisible --nocrashreport --nodefault --nofirststartwizard --nologo --norestore --accept=pipe,name=trytond;urp;StarOffice.ComponentContext
10050 ?        Sl     0:00 /usr/lib/libreoffice/program/soffice.bin --headless --invisible --nocrashreport --nodefault --nofirststartwizard --nologo --norestore --accept=pipe,name=trytond;urp;StarOffice.ComponentContext
10126 ?        Sl     0:00 /usr/lib/libreoffice/program/soffice.bin --headless --invisible --nocrashreport --nodefault --nofirststartwizard --nologo --norestore --accept=pipe,name=trytond;urp;StarOffice.ComponentContext
10776 ?        Sl     0:00 /usr/lib/libreoffice/program/soffice.bin --headless --invisible --nocrashreport --nodefault --nofirststartwizard --nologo --norestore --accept=pipe,name=trytond;urp;StarOffice.ComponentContext
10991 ?        Sl     0:00 /usr/lib/libreoffice/program/soffice.bin --headless --invisible --nocrashreport --nodefault --nofirststartwizard --nologo --norestore --accept=pipe,name=trytond;urp;StarOffice.ComponentContext
11254 ?        Sl     0:00 /usr/lib/libreoffice/program/soffice.bin --headless --invisible --nocrashreport --nodefault --nofirststartwizard --nologo --norestore --accept=pipe,name=trytond;urp;StarOffice.ComponentContext


Thanks in advanced for your help

--
Regards
Fabyc

Cédric Krier

unread,
Aug 20, 2016, 2:30:04 AM8/20/16
to try...@googlegroups.com
On 2016-08-04 10:27, Fabián wrote:
> In a test environment, Tryton is configured for converting invoice reports
> to PDF.
>
> This is the scenario:
>
> - User create invoice
> - When button "Pay" it's clicked, it sends automatically to the customer's
> email the invoice in PDF format.
> - After is sending (in the same click in button "Pay"), automatically it is
> opened the PDF report for printing.
> - Normally in server there is a temporary process [1] that disappears
> immediatly when both process (send PDF and open PDF) are done.
> - Many times Tryton hang up. Seems as it happens in the process when
> convert ODT to PDF. In server I see there a lot of processes in background.
> I put a few of them [2]. When processes are hang up, it is no possible to
> pay any invoice because of the problem.
>
> Changing the behavior for only send the PDF to email, there is not much
> hang ups, but the problem persist.

The conversion is made by using unoconv which is not completely reliable.
Some had better behaviour using socket instead of pipe, see
https://bugs.tryton.org/issue2703

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Fabyc

unread,
Aug 31, 2016, 1:06:12 PM8/31/16
to tryton
Hi Cédrik
I tested with the suggestion you gave me.

Now, there is not so much hangs up, but now sometimes I get this error [2].
If I try to open the same report a second time, it works. Sometimes in the third 
trying I can get the PDF report.

The error I get it no frequently.

Do you think the problem it is because of unoconv?

I get the same error when trying to open the invoice (PDF) directly from 
invoice module of core.


[2]
Traceback (most recent call last):
  File "/trytond/protocols/jsonrpc.py", line 150, in _marshaled_dispatch
    response['result'] = dispatch_method(method, params)
  File "/trytond/protocols/jsonrpc.py", line 179, in _dispatch
    res = dispatch(*args)
  File "/trytond/protocols/dispatcher.py", line 161, in dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/trytond/modules/own_module/ownmodule.py", line XXXX, in execute
    res = super(OwnReport, cls).execute(ids, data)
  File "/trytond/report/report.py", line 144, in execute
    type, data = cls.parse(action_report, records, data, {})
  File "/trytond/modules/own_module/ownmodue.py", line XXXX in parse
    localcontext=localcontext)
  File "/trytond/report/report.py", line 300, in parse
    data = cls.unoconv(data, report.template_extension, output_format)
  File "/trytond/report/report.py", line 320, in unoconv
    raise Exception(stderrdata)
Exception: None


Thanks

-- 
Best regards

Cédric Krier

unread,
Aug 31, 2016, 1:40:04 PM8/31/16
to tryton
On 2016-08-31 10:06, Fabyc wrote:
> I tested with the suggestion you gave me.
>
> Now, there is not so much hangs up, but now sometimes I get this error [2].
> If I try to open the same report a second time, it works. Sometimes in the
> third
> trying I can get the PDF report.
>
> The error I get it no frequently.
>
> Do you think the problem it is because of unoconv?

Yes, unoconv (Open/LibreOffice) is not so much stable.
Maybe someone could try abiword as an alternative to convert to PDF.

Jean Cavallo

unread,
Sep 19, 2016, 3:54:56 AM9/19/16
to try...@googlegroups.com

2016-08-04 17:27 GMT+02:00 Fabián <fabi...@gmail.com>:
- Many times Tryton hang up. Seems as it happens in the process when convert ODT to PDF. In server I see there a lot of processes in background. I put a few of them [2]. When processes are hang up, it is no possible to pay any invoice because of the problem.

We have had this problem for some time, and used the following approach :

  - Start a standalone unoconv server process
  - Patch trytond to connect to this running instance using pipe

Also, which version of office are you using ? We had a rather old
instance running which used LibreOffice version 3.5.4, and upgrading
to 4.X made a huge difference (still some crashes, but not nearly as
much as before).

Finally, you should check the child process error code (in the actual
call to unoconv), it contains the actual openoffice error code, which
may help you find the root cause.


Jean Cavallo
Coopengo

Cédric Krier

unread,
Sep 19, 2016, 4:20:04 AM9/19/16
to try...@googlegroups.com
On 2016-09-19 09:54, Jean Cavallo wrote:
> 2016-08-04 17:27 GMT+02:00 Fabián <fabi...@gmail.com>:
> - Patch trytond to connect to this running instance using pipe

The patch to replace wait by communicate is interesting as there is a
warning in the doc:
https://docs.python.org/2.6/library/subprocess.html#subprocess.Popen.wait

And the logger for bad returncode also.

The close_fds should only be set on non-Windows OS.

> See :
> https://github.com/coopengo/trytond/blob/master/trytond/report/report.py#L258

A patch will be welcomed.

Jean Cavallo

unread,
Sep 19, 2016, 4:36:14 AM9/19/16
to try...@googlegroups.com

2016-09-19 10:18 GMT+02:00 Cédric Krier <cedric...@b2ck.com>:
> 2016-08-04 17:27 GMT+02:00 Fabián <fabi...@gmail.com>:
>   - Patch trytond to connect to this running instance using pipe

The patch to replace wait by communicate is interesting as there is a
warning in the doc:
https://docs.python.org/2.6/library/subprocess.html#subprocess.Popen.wait

And the logger for bad returncode also.

The close_fds should only be set on non-Windows OS.

> See :
> https://github.com/coopengo/trytond/blob/master/trytond/report/report.py#L258

A patch will be welcomed.

We use the "--no-launch" flag in our command line, and we manually have
to start a unoconv process apart from the trytond process, so this would be
some sort of "breaking" change in the way the server start is handled.

Our deployment stack automatically handles restarting the unoconv process
when it crashes (it still happens randomly), but I do not see how we could
integrate it directly in the trytond server.

Jean Cavallo
Coopengo

Cédric Krier

unread,
Sep 19, 2016, 5:05:03 AM9/19/16
to try...@googlegroups.com
On 2016-09-19 10:35, Jean Cavallo wrote:
> 2016-09-19 10:18 GMT+02:00 Cédric Krier <cedric...@b2ck.com>:
>
> > > 2016-08-04 17:27 GMT+02:00 Fabián <fabi...@gmail.com>:
> > > - Patch trytond to connect to this running instance using pipe
> >
> > The patch to replace wait by communicate is interesting as there is a
> > warning in the doc:
> > https://docs.python.org/2.6/library/subprocess.html#subprocess.Popen.wait
> >
> > And the logger for bad returncode also.
> >
> > The close_fds should only be set on non-Windows OS.
> >
> > > See :
> > > https://github.com/coopengo/trytond/blob/master/trytond/
> > report/report.py#L258
> >
> > A patch will be welcomed.
>
>
> We use the "--no-launch" flag in our command line, and we manually have
> to start a unoconv process apart from the trytond process, so this would be
> some sort of "breaking" change in the way the server start is handled.

I did not talked about this flag.
Reply all
Reply to author
Forward
0 new messages