Call convert server api: ConvertService.ashx, return error: -3

i call convert api by following curl command:

# start test http server
ruby -run -e httpd . -p 8000

# request api by curl, my client ip is: 192.168.1.115
curl -H 'Content-Type: application/json' \
     -H 'Accept: application/json'  \
     -d '{"async":false,"url":"http://192.168.1.115:8000/file3.docx","outputtype":"pdf","filetype":"docx","title":"file3.docx","key":"personal_8199907371364626998_test_file3_4.docx","region":"zh"}' \
     -X POST \
      http://192.168.1.120:8001/ConvertService.ashx

then will get error return :
{error: -3 }
or
{“percent”:0,“endConvert”:false}

converter log output:

[2024-11-05T09:47:46.216] [ERROR] [localhost] [personal_8199907371364626998_test_file3_3.docx] [userId] nodeJS - stdout:
[2024-11-05T09:47:46.216] [ERROR] [localhost] [personal_8199907371364626998_test_file3_3.docx] [userId] nodeJS - stderr:TypeError: window.InitNativeEditors is not a function
    at <anonymous>:1:8
TypeError: window.InitNativeEditors is not a function
    at <anonymous>:1:8
TypeError: window.InitNativeEditors is not a function
    at <anonymous>:1:8
DoctRenderer:<result><error code="run" /></result>

[2024-11-05T09:47:46.217] [ERROR] [localhost] [personal_8199907371364626998_test_file3_3.docx] [userId] nodeJS - ExitCode (code=80;signal=null;error:-80)
[2024-11-05T09:51:33.873] [ERROR] [localhost] [personal_8199907371364626998_test_file3_4.docx] [userId] nodeJS - stdout:
[2024-11-05T09:51:33.874] [ERROR] [localhost] [personal_8199907371364626998_test_file3_4.docx] [userId] nodeJS - stderr:TypeError: window.InitNativeEditors is not a function
    at <anonymous>:1:8
TypeError: window.InitNativeEditors is not a function
    at <anonymous>:1:8
TypeError: window.InitNativeEditors is not a function
    at <anonymous>:1:8
DoctRenderer:<result><error code="run" /></result>

[2024-11-05T09:51:33.875] [ERROR] [localhost] [personal_8199907371364626998_test_file3_4.docx] [userId] nodeJS - ExitCode (code=80;signal=null;error:-80)

i don’t know the what cause this error, and how to resolve it. i hava searched the docservice codes ,can not found helpful information to resolve this error.

Hello @isNaN

Your curl is quite unexpected. Please try sending the request in following format:

curl --location 'http://documentserver/ConvertService.ashx' \
--header 'Content-Type: text/plain' \
--data '{
    "async": false,
    "filetype": "docx",
    "key": "key",
    "outputtype": "pdf",
    "title": "Document.docx",
    "url": "https://example.com/url-to-example-document.docx"
}'

In data you can specify all necessary parameters supported by Conversion service. You can find full list of them here: Conversion API

Note: if you are using JWT, make sure to sign the request.

Hi Constantine:

thanks return. I have tryied to send request by your command code, and get the same error.

$ curl --location http://192.168.1.120:8001/ConvertService.ashx \
     --header 'Content-Type: text/plain' \
     --data   '{"async":false,"url":"http://192.168.1.115:8000/file3.docx","outputtype":"pdf","filetype":"docx","title":"file3.docx","key":"personal_8199907371364626998_test_file3_5.docx" }'

command return data:

<?xml version="1.0" encoding="utf-8"?><FileResult><Error>-3</Error></FileResult>

Additional background information:

  1. Not use jwt
    
  2. OnlyOffice version: 8.1.3
    
  3. Operating System: Linux ETSME 4.19.232 #35 SMP Wed Oct 30 20:41:54 CST 2024 aarch64 GNU/Linux
    

my biggest puzzle is: “Where does the error ‘window.InitNativeEditors is not a function’ come from, and what causes it?” I couldn’t find any related keywords in the open-source code, and the Convert API documentation does not provide specific reasons for this error or mention an error code -80. Therefore, I’m unsure how to resolve this issue.

Try converting another file to see if it comes from this specific one. By the way, as I can see you are running Document Server in Docker, right? If so, check if your Document Server can access the file via provided link from inside the container. You can connect to the container with docker exec -it <ID> bash and get the file with, for instance, wget.

Yes, the server runing on docker,and i have tried to run onlyoffice on another device (not run in docker), also can not convert successfully, but the error log is difference。I have tried to convert some other format to pdf, the result is:

  1. docx => pdf,failed, convert error code: -80, log output
  2. pptx => pdf, failed, convert error code: -80
  3. xlsx => pdf, success :joy:

following is convert log output

[2024-11-06T13:15:37.498] [ERROR] [localhost] [test_file_demo1_1.docx] [userId] nodeJS - stderr:TypeError: Cannot read property 'length' of null
    at b.Pue (<anonymous>:17012:447)
    at b.Que (<anonymous>:17013:41)
    at d.mC (<anonymous>:17019:245)
    at Object.mC.Rue (<anonymous>:13140:49)
    at e.Yw (<anonymous>:13310:472)
    at Jo.y.hm (<anonymous>:20896:284)
    at xs.y.hm (<anonymous>:19414:58)
    at Gx (<anonymous>:20681:98)
    at Zd.y.eda (<anonymous>:19879:431)
    at Zd.y.sG (<anonymous>:19851:487)
DoctRenderer:<result><error code="calculate" /></result>

[2024-11-06T13:15:37.499] [ERROR] [localhost] [test_file_demo1_1.docx] [userId] nodeJS - ExitCode (code=80;signal=null;error:-80)
[2024-11-06T13:17:51.335] [ERROR] [localhost] [test_file_demo2_2.pptx] [userId] nodeJS - stdout:
[2024-11-06T13:17:51.338] [ERROR] [localhost] [test_file_demo2_2.pptx] [userId] nodeJS - stderr:TypeError: Cannot read property 'length' of null
    at b.rre (<anonymous>:16911:447)
    at b.sre (<anonymous>:16912:41)
    at d.gN (<anonymous>:16918:245)
    at Object.gN.KRf (<anonymous>:12964:228)
    at e.G5 (<anonymous>:13124:166)
    at b.e.Nnh (<anonymous>:12990:39)
    at b.e.Onh (<anonymous>:12988:493)
    at b.e.Eoc (<anonymous>:12987:37)
    at b.x1b (<anonymous>:22172:53)
    at <anonymous>:22171:248
DoctRenderer:<result><error code="calculate" /></result>

Does it happen with particular files or all of them? Can you try creating a simple document or presentation via Document Server and converting them too in test purposes?

Hello friends at OnlyOffice,

Thank you very much for your continued attention and patient responses to this issue over the past few days from several of your colleagues.

Let me briefly explain the background of this issue. The OnlyOffice service is running on a portable device within our company. This device requires strict security measures, meaning all program executions are strictly monitored, random programs cannot be run, and accessing the internet is not allowed. Therefore, it is not feasible to run the installation programs provided by OnlyOffice in the usual way on this device; modifications are necessary for deployment. Thus, we have taken the following steps to deploy the OnlyOffice docservice service onto the device:

  1. Run the OnlyOffice installation program on a device with the same hardware version that can access external networks (Linux + ARM).
  2. Copy the installed program’s runtime directory /var/www/onlyoffice/documentserver and configuration directory /etc/onlyoffice/documentserver to a mounted storage device on the target device.
  3. Create a Docker environment on the installation device and install nginx, plsql, activemq, etc., within the Docker environment.
  4. Manually initialize the database tables required by OnlyOffice.
  5. Use Docker’s bind mounts to map /var/www/onlyoffice, /var/logs/onlyoffice, and /etc/onlyoffice in the Docker environment to the directories where the installation files were copied.

After these modifications, the program runs smoothly in Docker, and the example services operate normally, allowing for file preview and system editing functions. However, the convert API fails to work correctly and throws an error.

From my exploration over the past few days, I have reached the following conclusions:

  1. The root cause of this problem appears to be the lack of certain third-party libraries needed for the convert functionality to operate properly, which are not located in the location specified by LD_LIBRARY_PATH. Alternatively, the LD_LIBRARY_PATH might include this third-party library, but the library could depend on operating system libraries that are missing. During my search, I found a relevant discussion which seems to reflect the same underlying issue: Errors that occur when using conversion APIs:error spawnAsync Error: Process exited with non-zero code: 80

  2. Although the convert API reports errors during execution, the DownloadAs and SaveAs functionalities in the OnlyOffice examples work fine, suggesting that the part of the convert API responsible for generating the post submission content for DownloadAS triggers this error, as they rely on the same service.

Therefore, my main questions are:

  1. Are all the dynamic libraries that OnlyOffice depends on included in the LD_LIBRARY_PATH? Which libraries are missing from this path? This would help us identify which library’s absence is causing this conversion error.

  2. Does the body content submitted via post for the DownloadAs feature match the content of the Editor.bin file? If not, what are the differences? I want to replace the body submitted by the browser with the corresponding Buffer from Editor.bin to call this API on the server side.

Thank you again for your attention and answers to this issue. I look forward to your replies.

(My limited English skills are insufficient to express this issue clearly, so this content has been translated using AI. I apologize in advance for any offense caused by potential translation errors.)


OnlyOffice 的朋友们你们好,非常感谢这些天多位 OnlyOffice 的同事对这个问题的持续关注和耐心回复。

简单说下这个产生这个问题的具备背景。首先 OnlyOffice 服务运行在我们公司的一台便携式设备上,
这个设备上的程序对安全性有要求,所有的程序的运行都被严格监控,不能随便运行程序,也不能访问外网。
因此在这个设备上是不能通过常规方式运行 OnlyOffice 官方提供的安装程序的,必须进行适当的改造才
可以进行部署。因此我们做了如下处理将 OnlyOffice 的 docservice 服务部署到了设备上。

  1. 在一台硬件版本相同且可以访问外的设备上(Linux + ARM)运行 OnlyOffice 安装程序
  2. 将安装后的程序按住后的运行文件目录:/var/www/onlyoffice/documentserver 和配置文件目录: /etc/onlyoffice/documentserver 拷贝到设备中 mount 的存储设备
  3. 在安装设备中创建 Docker 环境,并在 docker 环境中安装 nginx、 plsql、activemq…
  4. 手工初始化 onlyoffice 需要的数据库表
  5. 通过 docker 的 bind mounts 将 docker 环境的的 /var/www/onlyoffice、/var/logs/onlyoffice、 /etc/onlyoffice 映射到安装文件拷贝到的目录中

经过这样改造之后程序在 docker 中可以顺畅的运行,可以正常运行 example 服务,可以实现文件的预览和系统编辑功能。唯独 convert api 无法正常调用会报错。

经过这些天对这个文件的摸索,我暂时能得到如下结论:

  1. 这个问题的根本原因是:缺少一些 convert 正常运行所需要的第三方库,且这些第三方库没有位于 LD_LIBRARY_PATH 所指定的位置,亦或者 LD_LIBRARY_PATH 包含这个第三方库,但这个库可能依赖了操作系统库,而操作系统重缺乏对应的库。 我在搜索过程中找到了这个提问,这个问题应该和我这个问题本质上是一个问题:Errors that occur when using conversion APIs:error spawnAsync Error: Process exited with non-zero code: 80

  2. 虽然 convert api 运行会报错,但 onlyoffice 自带的 example 的 DownloadAs 和 SaveAs 功能却能正常运行,所以应该是 convert api 中生成 DownloadAS post 提交内容的这部分代码
    触发了这个错误, 因为这两个 API 依赖的服务和 convert api 依赖的服务是同一个。

所以我现在比较大的疑惑是:

  1. OnlyOffice 依赖的动态链接库,是否都位于 LD_LIBRARY_PATH 中,没有那些库是没有这里的?这样我们比较好排查到底缺失了那个库导致了这个转换错误
  2. DownloadAs 功能通过 post 提交的 body 内容与 Editor.bin 文件的内容一样吗? 如果不一样的话,差异是什么? 我想通过提交 Editor.bin 对应 Buffer 来替换浏览器提交的 body, 这样我可以在服务端调用这个 API。

再次感谢大家对这个问题的关注和解答,期待各位的回复。

(我蹩脚的英文不足以支撑我对这个问题进行表达,所以这段内容通过 AI 进行了翻译,如有因为 AI 翻译有误造成冒犯,在此先行道歉)

if you don’t mind I will join this thread as well.
Dear @isNaN, I do believe that the situation is related to your installation methods. In this very situation we need to rule out possible installation issues before continuing the troubleshooting.

Please deploy the Document Server from scratch following official guides:Installation Guides - Docs Community Edition - ONLYOFFICE
If you are using air-gapped server, please try this tested guide: Offline Installation - sourceforge download - #2 by Alexandre

Please follow official guides, re-deploy the Document Server and let us know the result.

Hello friends of OnlyOffice, thank you for your continuous attention and prompt responses to this issue in recent days. After debugging with node debugger and gdb debugger, my colleagues and I have finally identified the root cause of the problem. It was due to the absence of the /usr/shared/fonts directory in our docker environment. We have resolved the issue by mounting the Docker directory to /usr/shared/fonts outside of Docker.

Here is the error message that caused the C++ error during debugging:

(gdb) r /tmp/ASC_CONVERT20241021-dpvqqz.90um/params.xml
Starting program: /var/www/onlyoffice/documentserver/server/FileConverter/bin/x2t /tmp/ASC_CONVERT20241021-dpvqqz.90um/params.xml
warning: Error disabling address space randomization: Operation not permitted
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000007fa9d0eaf4 in CPdfWriter::GetFontPath(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, bool const&, bool const&, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, long&) ()
   from /var/www/onlyoffice/documentserver/server/FileConverter/bin/libPdfFile.so
(gdb) bt
#0  0x0000007fa9d0eaf4 in CPdfWriter::GetFontPath(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, bool const&, bool const&, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, long&) ()
   from /var/www/onlyoffice/documentserver/server/FileConverter/bin/libPdfFile.so
#1  0x0000007fa9d1187c in CPdfWriter::UpdateFont() () from /var/www/onlyoffice/documentserver/server/FileConverter/bin/libPdfFile.so
#2  0x0000007fa9d12174 in CPdfWriter::EncodeGID(unsigned int const&, unsigned int const*, unsigned int const&) ()
   from /var/www/onlyoffice/documentserver/server/FileConverter/bin/libPdfFile.so
#3  0x0000007fa9d1a048 in CPdfWriter::CommandDrawTextCHAR2(unsigned int*, unsigned int const&, unsigned int const&, double const&, double const&, double const&, double const&) () from /var/www/onlyoffice/documentserver/server/FileConverter/bin/libPdfFile.so
#4  0x0000007faaebd890 in NSOnlineOfficeBinToPdf::ConvertBufferToRenderer(unsigned char*, long, IMetafileToRenderter*) ()
   from /var/www/onlyoffice/documentserver/server/FileConverter/bin/libgraphics.so
#5  0x0000007fa9d2e744 in NSOnlineOfficeBinToPdf::ConvertBufferToPdf(CPdfFile*, unsigned char*, long, CConvertFromBinParams*) ()
   from /var/www/onlyoffice/documentserver/server/FileConverter/bin/libPdfFile.so
#6  0x0000007fa9d2ea74 in NSOnlineOfficeBinToPdf::ConvertBinToPdf(CPdfFile*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, bool, CConvertFromBinParams*) ()
   from /var/www/onlyoffice/documentserver/server/FileConverter/bin/libPdfFile.so
#7  0x0000007fa9d0a778 in CPdfFile::OnlineWordToPdfFromBinary(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, CConvertFromBinParams*) ()
   from /var/www/onlyoffice/documentserver/server/FileConverter/bin/libPdfFile.so
#8  0x00000000004ec78c in NExtractTools::bin2pdf(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, NExtractTools::InputParams&, NExtractTools::ConvertParams&) ()
#9  0x00000000004f5ea8 in NExtractTools::fromInputParams(NExtractTools::InputParams&) ()
#10 0x0000000000439120 in main ()

Hello @isNaN
Do I understand it right that the issue has been resolved?

Yes, the issue has been resolved. However, this error code is very ambiguous and can be very confusing for developers, making it difficult to pinpoint the specific reason for the problem. Is it possible to create a separate error code that throws an error if the directory “/usr/shared/fonts” is missing?