Cannot view PDF in OnlyOffice using Community Document Server

Nextcloud version (eg, 12.0.2): 18.0.3
Operating system and version (eg, Ubuntu 17.04): Debian 10
Apache or nginx version (eg, Apache 2.4.25): 2.4.38
PHP version (eg, 7.1): 7.3

The issue you are facing:

I am using Community Document Server bundled with NC and Onlyoffice plugin. I can view or edit .docx or .xslx or .odt files with no problems (so the server seems to be working and configuration paths must be correct, right?), but every time I try to view a PDF, i get “Connection is lost” error message.
If i uncheck PDF handling in OnlyOffice settings, I can open it properly (standard pdf.js viewer comes up). I was trying to test watermarking feature on PDFs as well (which itself is not related because disabling watermarks does not resolve the issue).

Steps to replicate it:

  1. Upload any PDF file
  2. Click on it
  3. Choose “open in OnlyOffice”

The output of config.php:

  'trusted_domains' =>
  array (
    0 => 'MYSERVER_FQDN',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '18.0.3.0',
  'overwrite.cli.url' => 'https://MYSERVER_FQDN',
  'htaccess.RewriteBase' => '/',
  'dbname' => '*******',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '**********',
  'dbpassword' => '*********',
  'installed' => true,
  'log_type' => 'file',
  'logfile' => '/var/www/nextcloud/data/nextcloud.log',
  'loglevel' => '0',
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\Memcache\\Redis',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'dbindex' => 0,
    'password' => '*********',
    'timeout' => 1.5,
  ),
  'default_language' => 'pl',
  'onlyoffice' =>
  array (
    'verify_peer_off' => true,
  ),

The output of your Nextcloud log in Admin > Logging:

{"reqId":"PRhpHESwjd7niE3Fwxkb","level":0,"time":"2020-03-30T17:33:03+00:00","remoteAddr":"xxx.xxx.xxx.xxx","user":"ncadmin","app":"onlyoffice","method":"GET","url":"/apps/onlyoffice/580?filePath=%2Ftest.pdf&infr
ame=true","message":"Open: 580 /test.pdf","userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0","version":"18.0.3.0"}
{"reqId":"lKcjCEICcMaHURm6Cl5H","level":0,"time":"2020-03-30T17:33:04+00:00","remoteAddr":"xxx.xxx.xxx.xxx","user":"ncadmin","app":"onlyoffice","method":"GET","url":"/apps/onlyoffice/ajax/config/580?filePath=%2Ft
est.pdf&inframe=2","message":"Config is generated for: 580 with key 852318558","userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0","version":"18.0.3.0"}
{"reqId":"a6gNfQwZHgMcSOz4DoDr","level":0,"time":"2020-03-30T17:33:06+00:00","remoteAddr":"xxx.xxx.xxx.xxx","user":"ncadmin","app":"no app in context","method":"POST","url":"/apps/documentserver_community/3rdpart
y/onlyoffice/documentserver/doc/852318558/c/694/cmpxs2bw/xhr_send?t=1585589585941","message":"Deprecated event type for \\OCP\\Files::preWrite: Symfony\\Component\\EventDispatcher\\GenericEvent","userAgent":"Moz
illa/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0","version":"18.0.3.0"}
{"reqId":"a6gNfQwZHgMcSOz4DoDr","level":0,"time":"2020-03-30T17:33:06+00:00","remoteAddr":"xxx.xxx.xxx.xxx","user":"ncadmin","app":"no app in context","method":"POST","url":"/apps/documentserver_community/3rdpart
y/onlyoffice/documentserver/doc/852318558/c/694/cmpxs2bw/xhr_send?t=1585589585941","message":"Deprecated event type for \\OCP\\Files::preCreate: Symfony\\Component\\EventDispatcher\\GenericEvent","userAgent":"Mo
zilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0","version":"18.0.3.0"}
{"reqId":"a6gNfQwZHgMcSOz4DoDr","level":0,"time":"2020-03-30T17:33:06+00:00","remoteAddr":"xxx.xxx.xxx.xxx","user":"ncadmin","app":"no app in context","method":"POST","url":"/apps/documentserver_community/3rdpart
y/onlyoffice/documentserver/doc/852318558/c/694/cmpxs2bw/xhr_send?t=1585589585941","message":"Deprecated event type for \\OCP\\Files::postWrite: Symfony\\Component\\EventDispatcher\\GenericEvent","userAgent":"Mo
zilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0","version":"18.0.3.0"}

The last line is repeated several times.

The output of Apache log:

xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:24 +0200] "GET /apps/onlyoffice/580?filePath=%2Ftest.pdf&inframe=true HTTP/1.1" 200 4931 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:24 +0200] "GET /apps/documentserver_community/web-apps/apps/api/documents/api.js HTTP/1.1" 304 263 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firef
ox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:25 +0200] "GET /apps/terms_of_service/terms HTTP/1.1" 200 5987 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:25 +0200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 200 1233 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:25 +0200] "GET /apps/onlyoffice/ajax/config/580?filePath=%2Ftest.pdf&inframe=2 HTTP/1.1" 200 1340 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefo
x/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:25 +0200] "POST /apps/text/session/sync HTTP/1.1" 200 1597 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:25 +0200] "GET /apps/documentserver_community/3rdparty/onlyoffice/documentserver/web-apps/apps/documenteditor/main/locale/pl.json HTTP/1.1" 304 263 "-" "Mozilla/5.0 (X11; Ub
untu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:25 +0200] "GET /apps/documentserver_community/3rdparty/onlyoffice/documentserver/sdkjs/common/libfont/wasm/fonts.wasm HTTP/1.1" 304 263 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:25 +0200] "GET /apps/documentserver_community/3rdparty/onlyoffice/documentserver/doc/852318558/c/info?t=1585589845971 HTTP/1.1" 200 879 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:26 +0200] "POST /apps/documentserver_community/3rdparty/onlyoffice/documentserver/doc/852318558/c/852/vu3e502s/xhr?t=1585589846289 HTTP/1.1" 200 874 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:26 +0200] "POST /apps/documentserver_community/3rdparty/onlyoffice/documentserver/doc/852318558/c/852/vu3e502s/xhr?t=1585589846380 HTTP/1.1" 200 1001 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:26 +0200] "POST /apps/documentserver_community/3rdparty/onlyoffice/documentserver/doc/852318558/c/852/vu3e502s/xhr?t=1585589846573 HTTP/1.1" 200 912 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:26 +0200] "POST /apps/documentserver_community/3rdparty/onlyoffice/documentserver/doc/852318558/c/852/vu3e502s/xhr_send?t=1585589846572 HTTP/1.1" 200 802 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:26 +0200] "POST /apps/documentserver_community/3rdparty/onlyoffice/documentserver/doc/852318558/c/852/vu3e502s/xhr?t=1585589846692 HTTP/1.1" 200 1138 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:26 +0200] "POST /apps/documentserver_community/3rdparty/onlyoffice/documentserver/doc/852318558/c/852/vu3e502s/xhr?t=1585589846799 HTTP/1.1" 200 1102 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:26 +0200] "POST /apps/documentserver_community/3rdparty/onlyoffice/documentserver/doc/852318558/c/852/vu3e502s/xhr?t=1585589846901 HTTP/1.1" 200 1027 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:27 +0200] "GET /apps/documentserver_community/open/852318558/Editor.bin HTTP/1.1" 200 13180 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:27 +0200] "GET /apps/documentserver_community/3rdparty/onlyoffice/documentserver/web-apps/apps/documenteditor/main/undefined HTTP/1.1" 404 13760 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:27 +0200] "GET /apps/documentserver_community/3rdparty/onlyoffice/documentserver/web-apps/apps/documenteditor/main/undefined HTTP/1.1" 404 13760 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
xxx.xxx.xxx.xxx - - [30/Mar/2020:19:37:27 +0200] "GET /apps/documentserver_community/3rdparty/onlyoffice/documentserver/web-apps/apps/documenteditor/main/undefined HTTP/1.1" 404 13760 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"

What looks really strange to me is these calls to undefined path.
I tried to disable redis/APCu caching, checked all the seemingly related threads regarding document server paths or x2t execute permissions - the issue persists. I am completely out of ideas.

I have something similar (just checked)…

It does not apply to all PDF files.
So for example, the PDF manual that comes with Nextcloud opens nicely in OnlyOffice.

Quick test:
If you use “Microsoft print to PDF” printer to produce the PDF, it will work.
If you use “Save as PDF” when printing from Chrome - it will not…

I have a standalone OO 5.4…

In my case Nextcloud manual PDF from 18.0.3 zip package also does not open.

I have the same Issue and error message, but not even the pdf created by onlyoffice itself are readable.
I am also using the Onlyoffice plugin from Nextcloud.

I am also having this issue. Opening any PDF will generate the error but excel, word documents take a while but it eventually pulls up.

I’m on 18.0.7 and using the OO plugin from within NextCloud.