ONLYOFFICE / onlyoffice-nextcloud

The app which enables the users to edit office documents from Nextcloud using ONLYOFFICE Document Server, allows multiple users to collaborate in real time and to save back those changes to Nextcloud
GNU Affero General Public License v3.0
565 stars 161 forks source link

BUG!? After update connection error in backend but not in frontend B #864

Open eeuak opened 1 year ago

eeuak commented 1 year ago

Hi, I have a very strange issue which occours now after updating to connector version 7.9.0 and NC version 26.0.5

When I save my Onlyoffice connector settings in the GUI in Nextcloud everything works fine, but every day at around 9:20 some kind of background job is running on NC which triggers an error message "Error occurred in the document service: Error while downloading the document file to be converted." which can be seen in nextcloud log. After that the connector looses the connection and I have to click "Save" (settings are still in the correspondig field) in the GUI to get onlyoffice running again.

I also found that the command "php8.1 occ onlyoffice:documentserver --check" triggers the exact same behavior. When I run this command the output is "Error connection: Error occurred in the document service: Error while downloading the document file to be converted." and the settings are reset in the gui. Then I again have to press save to get the connection back. This makes me assume that whatever cron job is running at 9:20 it triggers this command. This seems to me as wrong behavior because how can the gui successfully connect to the onlyoffice server but the backend connection check throws an error? (Please correct me if it's my configs fault that would make the whole thing easyer)

It was really hard to find the problem as there was absolutely no sign except of that onlyoffice in nextcloud wasnt available the past after 9 a.m....

I already looked around for the error message and tried different approaches for the connection configuration. Nothing helped for the error when triggering "php8.1 occ onlyoffice:documentserver --check".

I now stopped testing since it is a productive environment and we have a lot of people using this service. Currently I'm living with that every day I have to save the settings manually at around 9 a.m. but I hope you can help me to get rid of this as this is very unstable.

If you need any further info please let me know. Thanks a lot! Here you can see the logs that helped me find the problem:

Error message at 9:20 in nextcloud.log:

{"reqId":"M7U5lRyuZ2wEXI9uJw6m","level":3,"time":"2023-08-24T09:20:50+02:00","remoteAddr":"","user":"--","app":"onlyoffice","method":"","url":"--","message":"GetConvertedUri on check error","userAgent":"--","version":"26.0.5.1","exception":{"Exception":"Exception","Message":"Error occurred in the document service: Error while downloading the document file to be converted.","Code":0,"Trace":[{"file":"/var/www/notsocloud/apps/onlyoffice/lib/documentservice.php","line":95,"function":"ProcessConvServResponceError","class":"OCA\\Onlyoffice\\DocumentService","type":"->"},{"file":"/var/www/notsocloud/apps/onlyoffice/lib/documentservice.php","line":446,"function":"GetConvertedUri","class":"OCA\\Onlyoffice\\DocumentService","type":"->"},{"file":"/var/www/notsocloud/apps/onlyoffice/lib/cron/editorscheck.php","line":144,"function":"checkDocServiceUrl","class":"OCA\\Onlyoffice\\DocumentService","type":"->"},{"file":"/var/www/notsocloud/lib/public/BackgroundJob/Job.php","line":78,"function":"run","class":"OCA\\Onlyoffice\\Cron\\EditorsCheck","type":"->"},{"file":"/var/www/notsocloud/lib/public/BackgroundJob/TimedJob.php","line":103,"function":"start","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/notsocloud/lib/public/BackgroundJob/TimedJob.php","line":93,"function":"start","class":"OCP\\BackgroundJob\\TimedJob","type":"->"},{"file":"/var/www/notsocloud/cron.php","line":152,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/notsocloud/apps/onlyoffice/lib/documentservice.php","Line":241,"message":"GetConvertedUri on check error","CustomMessage":"GetConvertedUri on check error"}}

Why I think it is a background job:

{"file":"/var/www/notsocloud/cron.php","line":152,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/notsocloud/apps/onlyoffice/lib/documentservice.php","Line":241,"message":"GetConvertedUri on check error","CustomMessage":"GetConvertedUri on check error"}}

Corresponding error message when triggering the occ command on Onlyoffice server: /var/log/onlyoffice/documentserver/converter/out.log:

[2023-08-24T09:51:22.359] [ERROR] [localhost] [conv_check_88585172_docx] [userId] nodeJS - error downloadFile:url=https://cloud.my-domain.com/cloud/index.phphttps://cloud.my-domain.com/cloud/appshttps://cloud.my-domain.com/cloud/onlyofficehttps://cloud.my-domain.com/cloud/empty?doc=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY3Rpb24iOiJlbXB0eSJ9.eW7wRtQ9W88J_6H0dEirstYRVQ_7O5LuXkgeJpwetP0;attempt=2;code:undefined;connect:undefined Error: Error response: statusCode:404; headers:{"date":"Thu, 24 Aug 2023 07:51:22 GMT","server":"Apache/2.4.56 (Debian)","strict-transport-security":"max-age=15768000; includeSubDomains; preload","referrer-policy":"no-referrer","x-content-type-options":"nosniff","x-frame-options":"SAMEORIGIN","x-permitted-cross-domain-policies":"none","x-robots-tag":"noindex, nofollow","x-xss-protection":"1; mode=block","content-length":"281","keep-alive":"timeout=5, max=100","connection":"Keep-Alive","content-type":"text/html; charset=iso-8859-1"};
    at Request.fResponse (/snapshot/server/build/server/Common/sources/utils.js)
    at Request.emit (events.js:400:28)
    at Request.onRequestResponse (/snapshot/server/build/server/Common/node_modules/request/request.js:1059:10)
    at ClientRequest.emit (events.js:400:28)
    at HTTPParser.parserOnIncomingClient (_http_client.js:647:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:127:17)
    at HTTPParser.execute (<anonymous>)
    at TLSSocket.socketOnData (_http_client.js:515:22)
    at TLSSocket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:293:12)
    at readableAddChunk (internal/streams/readable.js:267:9)
    at TLSSocket.Readable.push (internal/streams/readable.js:206:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)

One thing I noticed is that the URL is very wrongly formatted, could this be the cause of the problems? And what makes this url look like this?: downloadFile:url=https://cloud.my-domain.com/cloud/index.phphttps://cloud.my-domain.com/cloud/appshttps://cloud.my-domain.com/cloud/onlyofficehttps://cloud.my-domain.com/cloud/empty?doc=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY3Rpb24iOiJlbXB0eSJ9.eW7wRtQ9W88J_6H0dEirstYRVQ_7O5LuXkgeJpwetP0

Thyroxine commented 1 year ago

I have exact the same problem - integration is disabled every 24 hours.

Nextcloud 26.0.5, Integration app v 7.9.0, Onlyoffice 7.4.1.36

Everything runs in Docker.

Thyroxine commented 1 year ago

Upgrade to Nextcloud 27.0.2 with app 8.2.0 does not solve the problem.

pwddel commented 1 year ago

For the first time I added this value to the wrong section, like this and It didn't work:

sudo -u apache php /var/www/html/nextcloud/occ config:system:set onlyoffice editors_check_interval --value='0'

For my environment, I solved this problem by adding editors_check_interval --value='0' like this:

sudo -u apache php /var/www/html/nextcloud/occ config:app:set onlyoffice editors_check_interval --value='0'

in Docker

docker exec -u www-data nextcloud-app php occ config:app:set onlyoffice editors_check_interval --value='0'

vitormattos commented 1 year ago

Hi @pwddel, If your idea is right, I think that maybe you solved the problem with the first command.

Look here, is the place that this value is used in the code:

https://github.com/ONLYOFFICE/onlyoffice-nextcloud/blob/04fc9bda2a2525af6c1f1a9490971319375c4d0c/lib/AppConfig.php#L1291C51-L1291C73

        $interval = $this->GetSystemValue($this->_editors_check_interval);

This row call the method GetSystemValue and this method do this:

https://github.com/ONLYOFFICE/onlyoffice-nextcloud/blob/04fc9bda2a2525af6c1f1a9490971319375c4d0c/lib/AppConfig.php#L349-L355

In all places is a request to IConfig::getSystemValue, this is to retrieve a value from config.php file

When you use occ config:app:set will save the setting in the database table appsettings and not in the config.php. In the code, to retrieve the value defined by config:app:set, is necessary to use the method getAppValue from a class that implement the interface IConfig but the method used in the code is getSystemValue.

To try your suggestion, you will need to use:

occ config:system:add onlyoffice editors_check_interval --value=0
vitormattos commented 1 year ago

A strange point at this method GetSystemValue of this app is because I think that the appName can't be changed. The appName need to be the same as the folder of app (onlyoffice) and also the same as the app_id (onlyoffice).

Maybe the problem could be this and the value of property appName is defined with different values depending of the point that this class is instantiated generating a wrong call of value of this system setting.

Is necessary to debug this code and check the scenarios.

Maybe will be best to make the appName with a hardcoded string with value onlyoffice. But, again, is necessary to debug this code and check the unit or integration tests of this app.

eeuak commented 1 year ago

If somebody would like to dive deeper into this error maybe start at

/apps/onlyoffice/lib/cron/editorscheck.php line 146

the $error here is filled with something which is why the script thinks there is an error. I didn't yet have time to check out the contents of $error but it could be help with further debugging.

I fixed it by setting $error to en empty value by:

    // Set the error to an empty value
    $error = "";

The script now thinks there is no error.

Altough this isn't a clean solution so I will likely implement @pwddel 's. Thanks for that!

Case isn't closed because it's still a bug!

Thyroxine commented 1 year ago

The solution with editors_check_interval does not work at all.

I've executed:

docker exec -u www-data nextcloud-app php occ config:app:set onlyoffice editors_check_interval --value='0'
docker exec -u www-data nextcloud-app php occ config:system:set onlyoffice editors_check_interval --value='0'

Now I have a section in config.php

'onlyoffice' => 
array (
    editors_check_interval => '0',
),

Anyway, the integration is still disabled every 24 hours.

carlou33 commented 1 year ago

don't work for me in NC 27.0.2 and OnlyOffice App 8.2.0

i have added in my config.php 'onlyoffice' => array ( editors_check_interval => '0', ),

with no result

leclou69 commented 1 year ago

Same problem here, NC 27.0.2.1, OnlyOfficeApp 8.2.0. I don't think that the core of the problem is, in which interval the check is done, but that it resolves in an error, even if you start it manually, i.e. with php occ onlyoffice:documentserver --check In the log I see the error "GetConvertedUri on check error" Well, the ConvertedUri is also displayed. I got my nextcloud-installation in a subdirectory, so its url is in the format "https://myhost.someddns.tld/nextcloud" I see in the error that the script tries to get some file from "https://myhost.someddns.tld/nextcloud/nextcloud/index.php/apps/onlyoffice/empty?doc=somethingweird" So it doubles the name of the subdirectory in the path. So I guess it is some error in building the uri. In the frontend, everything works like a charm.

Thanks in advance

eeuak commented 1 year ago

if setting editorscheck interval isn't solving it try my temp fix above.

SergeyKorneyev commented 1 year ago

The issue is with forming the URL for the background conversion task, we'll fix this on our side. In the meantime, please try specifying Nextcloud's address in the "Advanced server settings" section of the connector options (the last field there).

nook24 commented 1 year ago

I have exact the same problem.

Everything is running in Docker containers.

The issue is with forming the URL for the background conversion task, we'll fix this on our side. In the meantime, please try specifying Nextcloud's address in the "Advanced server settings" section of the connector options (the last field there).

Perfect, i will give this a try!

leclou69 commented 1 year ago

The issue is with forming the URL for the background conversion task, we'll fix this on our side. In the meantime, please try specifying Nextcloud's address in the "Advanced server settings" section of the connector options (the last field there).

No, error still persists when trying php occ onlyoffice:documentserver --check The URL keeps being misformed.

carlou33 commented 1 year ago

on test, it seems that the @SergeyKorneyev solution work for me

eeuak commented 1 year ago

The issue is with forming the URL for the background conversion task, we'll fix this on our side. In the meantime, please try specifying Nextcloud's address in the "Advanced server settings" section of the connector options (the last field there).

We had that setting specified too, didn't work. But thank you for looking into a fix.

nook24 commented 1 year ago

The issue is with forming the URL for the background conversion task, we'll fix this on our side. In the meantime, please try specifying Nextcloud's address in the "Advanced server settings" section of the connector options (the last field there).

Two days without any ONLYOFFICE server is not available error. Seems like this workaround works for me. Thanks @SergeyKorneyev

pmtirol commented 1 year ago

We have the same problem (NC 27.1.1; OnlyOffice App 8.2.0) tried the workaround from @SergeyKorneyev but alas, no luck.

SergeyKorneyev commented 1 year ago

We'll be releasing a hotfix soon that will include two main changes related to this new functionality:

  1. It will then be possible to correctly disable the background check by setting the 'editors_check_interval' parameter to 0. https://github.com/ONLYOFFICE/onlyoffice-nextcloud/pull/874
  2. 127.0.0.1 will be considered a valid address during the check. This is what's causing most of the issues. https://github.com/ONLYOFFICE/onlyoffice-nextcloud/pull/873

The official general recommendation is still to specify Nextcloud's address in the "Advanced server settings" to avoid issues with the check.

SergeyKorneyev commented 1 year ago

For anyone who would like to try out the fixes before they make it into the next connector version, here are the builds that include the changes (for manual installation):

pierreozoux commented 1 year ago

We applied this patch right now.

And php occ config:app:set onlyoffice editors_check_interval --value='0'

We'll report here if we have troubles.

But here we just disable the check, it is a nice workaround, I think, like in this issue that the check is buggy (having the admin notified that oo is down is a nice feature actually :) ).

Thanks for your help and have a nice day!

pierreozoux commented 1 year ago

Somehow, it still was running. I tried with this command ( I thouggh that maybe it was sensitive to string instead of int, but reading the code, it should'nt have been..): php occ config:app:set onlyoffice editors_check_interval --value=0 But same result.

We decided to remove the background job from info.xml and remove the cron folder.

I think this time this will work.

SergeyKorneyev commented 1 year ago

The version that includes the fixes (7.9.2/8.2.2) has just been released. Please try updating the connector and check if that helps.

adsche commented 1 year ago

We still have this problem.

Clicking 'Save' in the connector admin settings always works, occ onlyoffice:documentserver --check always fails (Error connection: Error occurred in the document service: Error while downloading the document file to be converted.).

The URLs are all set in the advanced settings.

I did now set editors_check_interval for app and system to 0, we'll know tomorrow if that helps, but that's certainly not the solution we'd want...

adsche commented 1 year ago

Update to my previous comment: Setting editors_check_interval to 0 did not help, the ONLYOFFICE server was disconnected again.

In case it's relevant: The server address provided is not localhost but a https URI. Everything works fine when the connection is established in the ONLYOFFICE connector admin settings until the disconnect happens once a day.

Is there a regression in 8.2.4? Is something wrong with the Docker image? Is there any way I can see what the actual error during the connection check is?

pierreozoux commented 1 year ago

For, us, this worked: remove the background job from info.xml and remove the cron folder.

adsche commented 1 year ago

For, us, this worked: remove the background job from info.xml and remove the cron folder.

Thanks, I'll try that. [I had read it before but was worried that it would stop other background processing (syncing files has been an issue before), but I read the source file in the folder and it indeed only seems to do this failing check.]

Edit: This worked, thanks!

eeuak commented 11 months ago

The version that includes the fixes (7.9.2/8.2.2) has just been released. Please try updating the connector and check if that helps.

Problem still occours, same behavior as my initial issue.

SergeyKorneyev commented 11 months ago

@eeuak What kind of errors do you get in the logs? Does disabling the cron job with "editors_check_interval = 0" help?

eeuak commented 11 months ago

@eeuak What kind of errors do you get in the logs? Does disabling the cron job with "editors_check_interval = 0" help?

No errors in the log. Disabling the cron job didn't work initially, I don't know if that changed since the last version but I also don't really want to test in our productive environment.

I patched it with my first solution for now:

If somebody would like to dive deeper into this error maybe start at

/apps/onlyoffice/lib/cron/editorscheck.php line 146

the $error here is filled with something which is why the script thinks there is an error. I didn't yet have time to check out the contents of $error but it could be help with further debugging.

I fixed it by setting $error to en empty value by:

    // Set the error to an empty value
    $error = "";

The script now thinks there is no error.

Altough this isn't a clean solution so I will likely implement @pwddel 's. Thanks for that!

Case isn't closed because it's still a bug!

adriangibanelbtactic commented 8 months ago

Once the editors_check_interval check is fixed I can confirm you that the right command for disabling this cron check is:

php occ config:system:set onlyoffice editors_check_interval --value=0

The config:app:set is not used at all in the current code.

adriangibanelbtactic commented 8 months ago

Feedback on this editors_check_interval check fix: https://github.com/ONLYOFFICE/onlyoffice-nextcloud/pull/960/commits/222223f212e6f66b5feba645a0ab0bce2d4b2961 which I have not been able to test as much as I would have wanted is welcome.

Thank you.

Update: No need of feedback for this commit. Apparently this is going to be fixed thanks to: https://github.com/ONLYOFFICE/onlyoffice-nextcloud/pull/965 in a future release.

rasos commented 3 months ago

Even with the standard interval of 1 day https://github.com/ONLYOFFICE/onlyoffice-nextcloud/pull/965/commits/e0b00c26b393c3d2e06c781c58de717f79b68d63#diff-8a773f79d952cb7c96f53ced13f5513dc2556bd373a355739742ef8a95378f56R1337 we have observed a much lower timespan (less than 1 hour) that the OO app decides, that the server is not anymore available and thus de-activates it. If we do maintenance on the OO server, we have to go through all Nexctlouds and in the OO admin settings press again SAVE after copy/pasting the same server address to activate it again.

Observed on NC 28.0.6 with OO 9.3 and also on other instances using an external OO server 7.5.1 on k8s.

ostasevych commented 2 months ago

Hi! Suddenly I have started to experience the similar issue. Are any chances to fix it or to add occ command which I can add to cron in order the Save button is clicked via script? Or as a workaround to restart the OO container at a specific time?

eeuak commented 2 weeks ago

Hi! Suddenly I have started to experience the similar issue. Are any chances to fix it or to add occ command which I can add to cron in order the Save button is clicked via script? Or as a workaround to restart the OO container at a specific time?

it's not a problem of saving, the problem is the check function. It can be deactivated as I wrote above. This is the only solution that helped me so far.