Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ONLYOFFICE failure with newest beta <MAJOR PROBLEM> #6497

Closed
WizWareTech opened this issue Aug 9, 2023 · 9 comments
Closed

ONLYOFFICE failure with newest beta <MAJOR PROBLEM> #6497

WizWareTech opened this issue Aug 9, 2023 · 9 comments

Comments

@WizWareTech
Copy link

What steps will reproduce the problem?

  1. Click 'Submit' button on ONLYOFFICE connector module configuration.
    or
  2. Try to open a document using ONLYOFFICE (for instance, click 'View Document' on 'Open File' dialog box)

What is the expected result?

When clicking submit, I expect the options to be saved.
When clicking 'View Document' I expect the document to open like it used to.

What do you get instead?

Error message shows up on bottom: "An unexpected server error occurred. If this keeps happening, please contact a site administrator."
Text for error is:
{
"url": "/onlyoffice/open?guid=86baf4b0-12b4-448b-ace6-cd54e83daf3d&mode=view",
"status": 500,
"response": {
"error": true,
"message": "An internal server error occurred."
},
"textStatus": "error",
"xhr": {
"readyState": 4,
"responseText": "{"error":true,"message":"An internal server error occurred."}",
"responseJSON": {
"error": true,
"message": "An internal server error occurred."
},
"status": 500,
"statusText": "error"
},
"dataType": "json",
"error": true,
"message": "An internal server error occurred.",
"errorThrown": "",
"validationError": false
}

Additional info

Q A
HumHub version 1.15.0-beta.1
PHP version 7.4.28
Operating system Linux

Note: Also provide the full error stacks from Administration --> Information --> Logging and errors from your browser console if possible.

ERROR Wed, 09 Aug 2023 10:59:44 -0600 ArgumentCountError
ArgumentCountError: Too few arguments to function Firebase\JWT\JWT::encode(), 2 passed in /var/www/humhub/protected/modules/onlyoffice/Module.php on line 273 and at least 3 expected in /var/www/humhub/protected/vendor/firebase/php-jwt/src/JWT.php:193
Stack trace:
#0 /var/www/humhub/protected/modules/onlyoffice/Module.php(273): Firebase\JWT\JWT::encode()
#1 /var/www/humhub/protected/modules/onlyoffice/controllers/AdminController.php(92): humhub\modules\onlyoffice\Module->commandService()
#2 /var/www/humhub/protected/modules/onlyoffice/controllers/AdminController.php(75): humhub\modules\onlyoffice\controllers\AdminController->validation()
#3 [internal function]: humhub\modules\onlyoffice\controllers\AdminController->actionSave()
#4 /var/www/humhub/protected/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#5 /var/www/humhub/protected/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#6 /var/www/humhub/protected/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()
#7 /var/www/humhub/protected/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction()
#8 /var/www/humhub/protected/vendor/yiisoft/yii2/base/Application.php(384): yii\web\Application->handleRequest()
#9 /var/www/humhub/index.php(25): yii\base\Application->run()
#10 {main}

Note: Please use the community site for any questions on customizing HumHub.

@ArchBlood
Copy link
Contributor

Should report this to OnlyOffice repo
https://github.com/ONLYOFFICE/onlyoffice-humhub

@luke- luke- closed this as completed Aug 10, 2023
@nicochto
Copy link

@WizWareTech Maybe a hint: I cannot reproduce your issue, however there is a report of a similar error in the Onlyoffice app for Nextcloud. Apparently the problem there was solved by adding a third argument "HS256" to the JWT::encode(…) function calls.

So you could try the same: Open the file /var/www/humhub/protected/modules/onlyoffice/Module.php mentioned in your error, and add this 3rd argument "HS256" to all occurences of the JWT::encode(…) call found in that file, like:

Module.php, line 273:
$data['token'] = JWT::encode($data, $this->getJwtSecret());
-->
$data['token'] = JWT::encode($data, $this->getJwtSecret(), "HS256");

(and do the same at line 274, 345, 346, and 399)

Good luck!

@WizWareTech
Copy link
Author

WizWareTech commented Aug 11, 2023

@nicochto,that fixed it! Now, when trying to open a doc with ONLYOFFICE, I get the same problem. I suspect I will need to make these changes throughout the rest of the code. Is that correct? Do you know all the places I need to adjust?

Here is the error:

{
"url": "/onlyoffice/open?guid=58b5edef-7b60-469c-85c1-c51f229d116f&mode=view",
"status": 500,
"response": {
"error": true,
"message": "An internal server error occurred."
},
"textStatus": "error",
"xhr": {
"readyState": 4,
"responseText": "{"error":true,"message":"An internal server error occurred."}",
"responseJSON": {
"error": true,
"message": "An internal server error occurred."
},
"status": 500,
"statusText": "error"
},
"dataType": "json",
"error": true,
"message": "An internal server error occurred.",
"errorThrown": "",
"validationError": false
}

@ArchBlood
Copy link
Contributor

@WizWareTech Maybe a hint: I cannot reproduce your issue, however there is a report of a similar error in the Onlyoffice app for Nextcloud. Apparently the problem there was solved by adding a third argument "HS256" to the JWT::encode(…) function calls.

So you could try the same: Open the file /var/www/humhub/protected/modules/onlyoffice/Module.php mentioned in your error, and add this 3rd argument "HS256" to all occurences of the JWT::encode(…) call found in that file, like:

Module.php, line 273:
$data['token'] = JWT::encode($data, $this->getJwtSecret());
-->
$data['token'] = JWT::encode($data, $this->getJwtSecret(), "HS256");

(and do the same at line 274, 345, 346, and 399)

Good luck!

Wouldn't it make more sense to wrap this in an array after all it's decoded in an array from the controller?

['HS256']

@nicochto
Copy link

@nicochto,that fixed it! Now, when trying to open a doc with ONLYOFFICE, I get the same problem. I suspect I will need to make these changes throughout the rest of the code. Is that correct? Do you know all the places I need to adjust?

Apparently there is only one other occurence of JWT::encode(), it is located in /var/www/humhub/protected/modules/onlyoffice/widgets/EditorWidget.php at line 208:
$token = JWT::encode($config, $module->getJwtSecret());
Inserting the 3rd argument "HS256" there as well is worth a try :-) But otherwise, sorry I have no idea. (When did your issue appear? Was it after some Onlyoffice update?)

@WizWareTech
Copy link
Author

You are a god! Problem fixed.

This started with the upgrade to the 1.15 beta. I thought it may have been due to some configuration change that conflicted with the older version of Onlyoffice I was running, so I upgraded it and it made no difference.

Adding the HS256 to everywhere you mentioned has fixed the issue. Can you see that it is rolled into next beta release so it's permanent? THANK YOU SO MUCH!!!

@nicochto
Copy link

That's great news, cheers!

Adding the HS256 to everywhere you mentioned has fixed the issue. Can you see that it is rolled into next beta release so it's permanent?

Well to be honest I have no idea how to do this, I'm new to Github. Maybe you should first move or recreate this issue in the OnlyOffice repo (https://github.com/ONLYOFFICE/onlyoffice-humhub) as suggested by @ArchBlood, since the issue and the fix are in the Onlyoffice module? Then we can propose the fix there? …and if we can't manage to do it, we'll ask again for help on https://community.humhub.com :-)

@luke-
Copy link
Contributor

luke- commented Aug 11, 2023

FYI, there is already a PR merged: https://github.com/ONLYOFFICE/onlyoffice-humhub/pull/99/files

@WizWareTech
Copy link
Author

I've been waiting for a beta update to be released but I still haven't seen one and am still having some issues with ONLYOFFICE.

Forgive my lack of knowledge, please. I see in this PR (99) there are 3 files updated. Can you tell me how I can go about applying these 3 updates to my existing installation to test and see if this fixes my issues? Obviously I can manually download and overwrite the 3 files, but I'm guessing there is a more automated way using git to do this. Can you help me with the right commands to run so I don't blow anything up? (and is there an automated way to back up those 3 files or should I just back them up manually before?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants