ONLYOFFICE 7.0: online forms, password protection in sheets, collaboration improvements and much more
ONLYOFFICE 7.0 released

"Download failed" error, example storage service trying to open file from wrong location

I am running document server with docker on a remote server(IP is 172.25.161.211):

docker run -i -t -d -p 80:80 onlyoffice/documentserver

the test example also been installed.

I am developing some web app to integrate with document server, which upload some docx file to the example, and then open a editor failed with “Download failed”, docker logs:

[2021-12-01T03:29:28.018] [ERROR] nodeJS - error downloadFile:url=http://172.25.161.211/example/download?fileName=a7d8f8de-05b8-4ec0-bd4e-0fb349132fc2.docx;attempt=3;code:null;connect:null;(id=Khirz6zTPdfd7)
Error: Error response: statusCode:500; headers:{"server":"nginx","date":"Wed, 01 Dec 2021 03:29:28 GMT","content-type":"text/html; charset=utf-8","content-length":"1095","connection":"keep-alive","x-powered-by":"Express","access-control-allow-origin":"*","etag":"W/\"447-PnbTeHgVWSyG80CT8TiPTuVOxcs\""}; body:
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <!--
    *
    * (c) Copyright Ascensio System SIA 2021
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    *     http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    *
    -->
    <title>Error</title>
</head>
<body>
    <hgroup>
        <h1>Error.</h1>
        <h2>An error occurred while processing your request.</h2>
    </hgroup>
    <div>ENOENT: no such file or directory, stat &#39;/var/lib/onlyoffice/documentserver-example/files/172.17.0.1/a7d8f8de-05b8-4ec0-bd4e-0fb349132fc2.docx&#39;</div>
</body>
</html>
    at Request._callback (/snapshot/server/build/server/Common/sources/utils.js:0:0)
    at Request.init.self.callback (/snapshot/server/build/server/Common/node_modules/request/request.js:185:22)
    at Request.emit (events.js:198:13)
    at Request.<anonymous> (/snapshot/server/build/server/Common/node_modules/request/request.js:1154:10)
    at Request.emit (events.js:198:13)
    at IncomingMessage.<anonymous> (/snapshot/server/build/server/Common/node_modules/request/request.js:1076:12)
    at Object.onceWrapper (events.js:286:20)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
[xwiki@VM_161_211_centos ~]$ docker exec -it 1b16 /bin/bash
root@1b16a5c7890f:/# ls /var/lib/onlyoffice/documentserver-example/files
172.17.0.1  172.30.7.4
root@1b16a5c7890f:/# ls /var/lib/onlyoffice/documentserver-example/files/172.30.7.4/
a7d8f8de-05b8-4ec0-bd4e-0fb349132fc2.docx  a7d8f8de-05b8-4ec0-bd4e-0fb349132fc2.docx-history  b3d3e606-bf5f-43e8-ae9d-6419353e346e.docx  b3d3e606-bf5f-43e8-ae9d-6419353e346e.docx-history

172.30.7.4 is my local machine’s IP, but the document server is trying to find uploaded file in folder 172.17.0.1
seems the test example store uploaded file in folder named as client’s ip, how to specify the document.url then ?

my code:

const openDoc = function (body, node, file) {
    const url = 'http://172.25.161.211/example/upload'
    const DOC_NAME = uuid() + '.docx'
    console.log(file)
    console.log('upload to oo as file ' + DOC_NAME)
    var formdata = new FormData()
    formdata.append('uploadedFile', file, DOC_NAME)
    formdata.append('fileName', DOC_NAME)
    var requestOptions = {
        method: 'POST',
        body: formdata,
        redirect: 'follow'
    }
    fetch(url, requestOptions)
        .then((res) => {
            const script = document.createElement('script')
            script.id = ''
            script.append(`
                config = {
                    document: {
                        fileType: 'docx',
                        key: 'Khirz6zTPdfd7',
                        title: '${DOC_NAME}',
                        url: 'http://172.25.161.211/example/download?fileName=${DOC_NAME}'
                    },
                    documentType: 'word'
                }
                var docEditor = new DocsAPI.DocEditor('${node.id}', config)`)
            body.appendChild(script)
        })
        .catch((err) => {
            console.error(err)
        })
}

Hello,
In our test examples files created/uploaded by users are stored in directories named after the IP address from which the user accessed the example. You may change the way the documents are stored in any way you wish. In your case it seems your IP has changed and you are no longer able to open the file. Do you use any proxy/VPN?

Yes I am using a http proxy, but document server is listed in “no_proxy” variable.

Also I noticed that 172.17.0.1 is actually the address of docker0 interface.

don’t know why onlyoffice trying to find my file under that folder(172.17.0.1)

I have inspected how the example UI works using chrome dev tools, found that when it create
DocsAPI.DocEditor, a useraddress=172.30.7.4 is added as URL parameter. but I think it’s generated from server side, but I do all things in pure javascript, it’s also tricky and unreliable to get local IP address in javascript.