Running OnlyOffice with Docker-Compose - WOPI - Connection refused while connecting to upstream

You have to implement headers to enable forcesave feature and set up the Save button. Please take a look at these titles:
https://api.onlyoffice.com/editors/faq/saving
https://api.onlyoffice.com/editors/wopi/restapi/putfile

It looks like you need these headers:
headers[‘X-LOOL-WOPI-IsModifiedByUser’] = isModifiedByUser;
headers[‘X-LOOL-WOPI-IsAutosave’] = isAutosave;
headers[‘X-LOOL-WOPI-IsExitSave’] = isExitSave;

Ah! Thanks! This sounds promising. I will try this out…

1 Like

@Alexandre I try to figure out how set the correct parameter and I wonder if I can use the WOPI PostMessage for this?
After I receifed the App_LoadingStatus during loading the document, I tried to send the request like this:

iframe.postMessage(JSON.stringify({"c": "forcesave","key": "Khirz6zTPdfd7","userdata": "sample userdata"}), '*');

But this did no work.
Also I tried to update the default.json in my docker container by providing a customized version with

		"autoAssembly": {
			"enable": true,
			"interval": "1m",
			"step": "1m"
		},

But this also does not have any effect.
From the description of this page it seems that setting forceSave should have effect, that I got the WOPI Post Request each time the user press the save button inside onlyOffice. But until now it did not work for me.

Can you give me a short example how to use the Command service to tell OnlyOffice to change its behaviour?

Hi @Alexandre,
I think I solved the problem more or less by changing the default.json file configuration with the following setting:

			"autoAssembly": {
				"enable": true,
				"interval": "0m",
				"step": "0m"
			},

So I set both parameters to “0m”. The “step” parameter seems not to be documented - at least I did not found any information about it, but I think it should also be set to 0m too.

At least I did not understand why I should wait 1 or 5 minutes until my WOPI host receive the fresh document from the OnlyOffice documentServer.

I will try to explain the situation: We are developing an open source workflow suite (https://github.com/imixs/imixs-office-workflow). Users can create or process a process instance and can add any kind of information to it.
With the integration of OnlyOffice we want to offer our customers a way to edit documents via OnlyOffice. But from our Worklfow-perspective, the user can edit any kind of form data, add documents or at least edit existing documents with OnlyOffice.
When the user triggers the Workflow Action (e.g. save, approve, reject) we store all information including the documents into the workflow storage. The timestamp is an important data here. We generate a protocol over all data this user has added/changed. After a process step it may be that the workflow instance and all its data is now locked (e.g. archived) and it is not allowed any more to change it.

And for this reason I need the updated version from OnlyOffice immediately after the user clicks in OnlyOffice on the save button. Processing information depends on business rules within our BPMN process model and this is far outside of logic of the documentStorage from OnlyOffice.

I think from the perspective of OwnCloud or NextCloud the situation is much more easy and your idea to wait a little bit until all users have finished editing is fine. But in your workflow scenario it is not possible to change the document after the user has finished his task.

See the screen cast below for better understanding the situation:

Peek 2022-07-08 19-16

iframe.postMessage(JSON.stringify({“c”: “forcesave”,“key”: “Khirz6zTPdfd7”,“userdata”: “sample userdata”}), ‘*’);

It looks correct. Could you please reproduce the issue and provide us with whole Document server logs folder?

As for autoAssembly parameter. It is not needed in your scenario (Save button). This parameter is related to timely auto save process.

Hi @Alexandre

I added a javascript to post the message:

function setOnlyOfficeForcesave() {
	
	console.log('setOnlyOfficeForcesave.....');
	var iframe = document.getElementById('wopi-iframe');
	iframe = iframe.contentWindow || (iframe.contentDocument.document || iframe.contentDocument);
	if (iframe) {
		console.log('post message...');
		iframe.postMessage(JSON.stringify({"c": "forcesave","key": "Khirz6zTPdfd7","userdata": "sample userdata"}), "*");
		console.log('post message completed!');
	} else {
		console.log('iframe not found!');
	}
}

The postMessage is executed without errors but I did not see any changes in behaviour.
I created a tar file from my documentserver logs. How can I provide you this file? I can not upload the file into this forum (?).

===
Ralph

You can download the logs from our server:
https://manik.imixs.org/documentserver_20220711.tar.gz
Please let me know if you got them so I can remove the tar file.

Thank you for the logs. We got it. We need some time to check it out.

We noticed an oddity in provided logs:

[2022-07-11T16:22:59.282] [ERROR] nodeJS - dnsLookup error: hostname = imixs-documents
Error: getaddrinfo ENOTFOUND imixs-documents
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:69:26)

It looks like DS doesn’t know where the storage app is.
We have checked your compose file from first post:

imixs-documents:
    image: imixs/imixs-documents:latest
    environment:
      WOPI_PUBLIC_ENDPOINT: "localhost:80/"
      WOPI_DISCOVERY_ENDPOINT: "onlyoffice-app:80/hosting/discovery"
      WOPI_HOST_ENDPOINT: "imixs-documents:8080/api/wopi/"
    ports:
      - "8080:8080"

  onlyoffice-app:
    image: onlyoffice/documentserver
    container_name: onlyoffice-app
    expose:
      - 80
    ports:
      - "80:80"
    environment:
      WOPI_ENABLED: "true"

Probably you need to specify container name as you did it for DS:
container_name: imixs-documents
Or you need to resolve the situation in /etc/hosts file of DS container. Anyway this error looks like DNS issue.

Yes, I also have the impression that resolving the host names goes totally wrong. The supprising thing is, that OnlyOffice is of course able to call the checkFileInfo WOPI Call against "imixs-documents:8080/ and also fetch the file. This is expected in a docker-compose situation. But the nginx sever seems to try to resolve localhost:8080 which is the referer host when you have the perspective from the web application.
And this is the reason why I am missing a parameter to tell OnlyOffice (or the documentserver) the correct internal host name of my WOPI Host. Of course both docker containers can communicate with each other. And: everything is working with this development setup !? - very strange.

To describe the problem from a more broad perspective: I plan to setup the complete solution for our customers in Kubernetes. And also in this environment I expect that the document sever uses the internal POD host names provided by the internal Kubernetes network and not communicate via the official Internet DNS name. I expect the issue will be gone if I setup the connection via internet domains. But is it, what you expect/recommand? For the Web part with javascript in the browser I understand this. But for communication between documentserver and WOPI Host should it not be better to avoid going outside for security reason?

Maybe you can provide some architecture pictures to explain your ideal setup. This is also a interesting question, when my customer what to buy your Enterprise Solution. How should the setup look like in various scenarios?

Sorry, but I must come back to the forcesave flag issue.

What would you expect if I call the following script from the parent window:

iframe.postMessage(JSON.stringify({"c": "forcesave","key": "Khirz6zTPdfd7","userdata": "sample userdata"}), "*");
		

How can I verify what happend on the server or if the command was successfull or not. I absolutily did not understand how to verifiy this.
Please be aware that I am running wopi_enabled=true mode

How can I verify what happend on the server or if the command was successfull or not.

You can check DEBUG logs on the Document server side to check it out. There will be PutFile request in the logs.
How to enable DEBUG logs:

  1. Open /etc/onlyoffice/documentserver/log4js/production.json (for Docker - all actions performed inside the container);

  2. Change “level”: “WARN” to “level”: “DEBUG

  3. Execute supervisorctl restart all to apply the changes

And also in this environment I expect that the document sever uses the internal POD host names provided by the internal Kubernetes network and not communicate via the official Internet DNS name

Here’s the official guide for Kubernetes:

Please note that we are still testing WOPI for K8s. We are going to add it as variable for pods in the next Helm Docs update.

Hi @Alexandre , I can activate the DEBUG mode. This works fine and I can see now many debug messages.
But my PostMessage did not work and also did not generate any additional debug message.

I analysed the situation in more detail. And maybe we are talking about different things.
Remember, I am in the WOPI Situation, which means my web application generates an iframe element to load the OnlyOffice editor based on the WOPI Discovery URL result. This works fine.
My iframe contains a document with again an iframe containing the OnlyOffice app.

Don’t you think, that my postMessage is going to the WOPI API and not to the command service?
This is the script I am using out from my web app to post the message:

function setOnlyOfficeForcesave() {
	
	console.log('setOnlyOfficeForcesave.....');
	var iframe = document.getElementById('wopi-iframe');
	iframe = iframe.contentWindow || (iframe.contentDocument.document || iframe.contentDocument);
	if (iframe) {
		console.log('post message to localhost...');
		//var result=iframe.postMessage(JSON.stringify({"c": "forcesave","key": "Khirz6zTPdfd7","userdata": "true"}), "*");
		var result=iframe.postMessage(JSON.stringify({"c": "forcesave","key": "Khirz6zTPdfd7","userdata": "imixs-workflow"}), "http://localhost:80/coauthoring/CommandService.ashx");
		console.log('post message completed! result='+result);
	} else {
		console.log('iframe not found!');
	}
}

No errors, but I did not get a result (undefined) and I can’t see anything in the debug log.

Do you expect that in case of a WOPI integration it should be possible to post normal OnlyOffice Command Service in parallel to the WOP PostMessage commands? Even if they have different formats?

https://api.onlyoffice.com/editors/command/

https://api.onlyoffice.com/editors/wopi/postmessage

What I mean is that I fear my JavaScript function has the wrong implementation for that what we want to achieve - setting the forceSave flag?

Could you please reproduce the situation and send us debug logs? You can contact me in PM

Hi @Alexandre, you will find the new logfiles here:
https://manik.imixs.org/documentserver_20220715.tar.gz

Thank you for the logs, we are checking the situation.

Hello @rsoika
Sorry for the late reply. Please accept our apologies for current situation. We are still working to improve WOPI on Document server.
As for forcesave scenario in general. There’s no desired mechanism for forcesave feature in WOPI at the moment. We are working on it.
There are only two ways to achieve desired scenario at the moment:

  1. Switch WOPI to usage API.
  2. Implement your own external Save button (not in the editor frame). This scenario should look like this: your server sends request to CommandService.ashx (ONLYOFFICE Api Documentation - Command service ) for checking file in Document server cache\build it\send to a storage.

Hi @Alexandre
thanks for your reply. No problem at all. If I know you are working on this it is fine. Can I track the issue on Github? Maybe I can also support your dev team with early testing.

For the moment I solved the problem somehow with the property settings for coauthoring:

{
  "services": {
    "CoAuthoring": {
      "autoAssembly": {
        "enable": true,
        "interval": "0m",
        "step": "0m"
      }
    }
  },
  "wopi": {
    "enable": true
  }
}

I can see in the logs that this not not ideal and costs a lot of CPU.

As I mentioned before, I think the doc/faq are not up to date:
https://api.onlyoffice.com/editors/faq/saving

But it is fine if you trigger me via this thread if a new version of the WOPI api is available. I prefer the WOPI API against the ONLYOFFICE API because an open standard protocol fits better in our own Open Source strategy.

Thank you for your testing offer, but I believe that our QA team deal with it. We have a lot of work to do to improve WOPI. I will notify you in this thread when we implement forcesave feature for WOPI.
As for autoAssembly parameter, as I mentioned before, this is not a right way in forcesave scenario (save button), but I understand why you looked at it in your scenario.
I will be in touch and provide you with any news about WOPI.

1 Like

Hi, are there any news about the WOPI Interface in OnlyOffice?