ONLYOFFICE / document-server-integration

Examples on how to integrate ONLYOFFICE Document Server into your own website or application
Apache License 2.0
146 stars 112 forks source link

Python Example "The document could not be saved" and "Download Failed" errors. #447

Open yokesh22 opened 1 year ago

yokesh22 commented 1 year ago

I have used Python Example provided in this url "https://api.onlyoffice.com/editors/demopreview". I have change STORAGE_PATH and DOC_SERV_SITE_URL. Config.py

import os

VERSION = '1.5.1'

FILE_SIZE_MAX = 5242880
STORAGE_PATH = 'assets/new'

DOC_SERV_FILLFORMS = [".oform", ".docx"]
DOC_SERV_VIEWED = [".pdf", ".djvu", ".xps", ".oxps"]  # file extensions that can be viewed
DOC_SERV_EDITED = [".docx", ".xlsx", ".csv", ".pptx", ".txt", ".docxf"]  # file extensions that can be edited
DOC_SERV_CONVERT = [                                           # file extensions that can be converted
    ".docm", ".doc", ".dotx", ".dotm", ".dot", ".odt",
    ".fodt", ".ott", ".xlsm", ".xlsb", ".xls", ".xltx", ".xltm",
    ".xlt", ".ods", ".fods", ".ots", ".pptm", ".ppt",
    ".ppsx", ".ppsm", ".pps", ".potx", ".potm", ".pot",
    ".odp", ".fodp", ".otp", ".rtf", ".mht", ".html", ".htm", ".xml", ".epub", ".fb2"
]

DOC_SERV_TIMEOUT = 120000

DOC_SERV_SITE_URL = 'http://192.168.1.119:8050/'

DOC_SERV_CONVERTER_URL = 'ConvertService.ashx'
DOC_SERV_API_URL = 'web-apps/apps/api/documents/api.js'
DOC_SERV_PRELOADER_URL = 'web-apps/apps/api/documents/cache-scripts.html'
DOC_SERV_COMMAND_URL='coauthoring/CommandService.ashx'

EXAMPLE_DOMAIN = "http://192.168.1.119:8050"

secret_key = os.urandom(32).hex()

DOC_SERV_JWT_SECRET = "my_jwt_secret"  # the secret key for generating token
DOC_SERV_JWT_HEADER = 'Authorization'

DOC_SERV_VERIFY_PEER = False

EXT_SPREADSHEET = [
    ".xls", ".xlsx", ".xlsm", ".xlsb",
    ".xlt", ".xltx", ".xltm",
    ".ods", ".fods", ".ots", ".csv"
]

EXT_PRESENTATION = [
    ".pps", ".ppsx", ".ppsm",
    ".ppt", ".pptx", ".pptm",
    ".pot", ".potx", ".potm",
    ".odp", ".fodp", ".otp"
]

EXT_DOCUMENT = [
    ".doc", ".docx", ".docm",
    ".dot", ".dotx", ".dotm",
    ".odt", ".fodt", ".ott", ".rtf", ".txt",
    ".html", ".htm", ".mht", ".xml",
    ".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oxps", ".oform"
]

LANGUAGES = {
    'en': 'English',
    'hy': 'Armenian',
    'az': 'Azerbaijani',
    'eu': 'Basque',
    'be': 'Belarusian',
    'bg': 'Bulgarian',
    'ca': 'Catalan',
    'zh' : 'Chinese (People\'s Republic of China)',
    'zh-TW' : 'Chinese (Traditional, Taiwan)',
    'cs': 'Czech',
    'da': 'Danish',
    'nl': 'Dutch',
    'fi': 'Finnish',
    'fr': 'French',
    'gl': 'Galego',
    'de': 'German',
    'el': 'Greek',
    'hu': 'Hungarian',
    'id': 'Indonesian',
    'it': 'Italian',
    'ja': 'Japanese',
    'ko': 'Korean',
    'lv': 'Latvian',
    'lo': 'Lao',
    'ms': 'Malay (Malaysia)',
    'nb': 'Norwegian',
    'pl': 'Polish',
    'pt' : 'Portuguese (Brazil)',
    'pt-PT' : 'Portuguese (Portugal)',
    'ro': 'Romanian',
    'ru': 'Russian',
    'sk': 'Slovak',
    'sl': 'Slovenian',
    'es': 'Spanish',
    'sv': 'Swedish',
    'tr': 'Turkish',
    'uk': 'Ukrainian',
    'vi': 'Vietnamese',
    'aa-AA': 'Test Language'
}

if os.environ.get("EXAMPLE_DOMAIN"):  # generates a link for example domain
    EXAMPLE_DOMAIN = os.environ.get("EXAMPLE_DOMAIN")
if os.environ.get("DOC_SERV"):  # generates links for document server
    DOC_SERV_SITE_URL = os.environ.get("DOC_SERV")

now when i am opening a file or creating new file from document list (document manager). I'm getting error as "The document could not be saved". and followed by "Download Failed". The url showing when opening a new is "http://localhost:8000/edit?filename=new.docx"

where to run python i give cmd as python3 manage.py runserver 0.0.0.0:8000

this is my out.log

[2023-08-24T06:53:48.712] [ERROR] [localhost] [6289806449775634934] [uid-1] nodeJS - postData error: url = http://192.168.1.119:8050/track?filename=new%20(2).docx&userAddress=127.0.0.1;data = {"key":"6289806449775634934","status":1,"users":["uid-1"],"actions":[{"type":1,"userid":"uid-1"}],"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiI2Mjg5ODA2NDQ5Nzc1NjM0OTM0Iiwic3RhdHVzIjoxLCJ1c2VycyI6WyJ1aWQtMSJdLCJhY3Rpb25zIjpbeyJ0eXBlIjoxLCJ1c2VyaWQiOiJ1aWQtMSJ9XSwiaWF0IjoxNjkyODYwMDI4LCJleHAiOjE2OTI4NjAzMjh9.sS13MyF2CDlBl0yzh84HWkQAHqXMj4UrhBmCKyNUuMM"} Error: Error response: statusCode:404; headers:{"server":"nginx","date":"Thu, 24 Aug 2023 06:53:48 GMT","content-type":"text/html; charset=utf-8","transfer-encoding":"chunked","connection":"keep-alive","vary":"Accept-Encoding","content-security-policy":"default-src 'none'","x-content-type-options":"nosniff","content-encoding":"gzip"}; body:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /track</pre>
</body>
</html>

    at Request._callback (/snapshot/server/build/server/Common/sources/utils.js)
    at Request.callback (/snapshot/server/build/server/Common/node_modules/request/request.js:185:22)
    at Request.emit (events.js:400:28)
    at Request.<anonymous> (/snapshot/server/build/server/Common/node_modules/request/request.js:1154:10)
    at Request.emit (events.js:400:28)
    at Gunzip.<anonymous> (/snapshot/server/build/server/Common/node_modules/request/request.js:1076:12)
    at Object.onceWrapper (events.js:519:28)
    at Gunzip.emit (events.js:400:28)
    at endReadableNT (internal/streams/readable.js:1333:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
SergeyKorneyev commented 12 months ago

Hello,

The value of DOC_SERV_SITE_URL should contain the Document Server's (ONLYOFFICE Docs) address, so please double-check if it's available at that address. The value of EXAMPLE_DOMAIN should either be left default (None) or it should be http://192.168.1.119:8000 in your case. If you leave it as None, then you should access the example via its IP address instead of localhost.

github-ljx commented 10 months ago

When I use the provided Python example, the view page opens correctly, but the edit page fails to display properly as shown in the image below. image

Upon checking the logs of the Document Server container, the following error message can be observed. image

I have change DOC_SERV_SITE_URL. Config.py

import os

VERSION = '1.6.0'

FILE_SIZE_MAX = 5242880
STORAGE_PATH = 'app_data'

DOC_SERV_FILLFORMS = [".docx", ".oform"]
DOC_SERV_VIEWED = [".djvu", ".oxps", ".pdf", ".xps"]  # file extensions that can be viewed
DOC_SERV_EDITED = [                                             # file extensions that can be edited
    ".csv", ".docm", ".docx", ".docxf", ".dotm", ".dotx",
    ".epub", ".fb2", ".html", ".odp", ".ods", ".odt", ".otp",
    ".ots", ".ott", ".potm", ".potx", ".ppsm", ".ppsx", ".pptm",
    ".pptx", ".rtf", ".txt", ".xlsm", ".xlsx", ".xltm", ".xltx"
]
DOC_SERV_CONVERT = [                                            # file extensions that can be converted
    ".doc", ".dot", ".dps", ".dpt", ".epub", ".et", ".ett", ".fb2",
    ".fodp", ".fods", ".fodt", ".htm", ".html", ".mht", ".mhtml",
    ".odp", ".ods", ".odt", ".otp", ".ots", ".ott", ".pot", ".pps",
    ".ppt", ".rtf", ".stw", ".sxc", ".sxi", ".sxw", ".wps", ".wpt",
    ".xls", ".xlsb", ".xlt", ".xml"
]

DOC_SERV_TIMEOUT = 120000

DOC_SERV_SITE_URL = 'http://192.168.2.100:6831/'

DOC_SERV_CONVERTER_URL = 'ConvertService.ashx'
DOC_SERV_API_URL = 'web-apps/apps/api/documents/api.js'
DOC_SERV_PRELOADER_URL = 'web-apps/apps/api/documents/cache-scripts.html'
DOC_SERV_COMMAND_URL='coauthoring/CommandService.ashx'

EXAMPLE_DOMAIN = None

DOC_SERV_JWT_SECRET = ''  # the secret key for generating token
DOC_SERV_JWT_HEADER = 'Authorization'
DOC_SERV_JWT_USE_FOR_REQUEST = True

DOC_SERV_VERIFY_PEER = False

EXT_SPREADSHEET = [
    ".xls", ".xlsx", ".xlsm", ".xlsb",
    ".xlt", ".xltx", ".xltm",
    ".ods", ".fods", ".ots", ".csv"
]

EXT_PRESENTATION = [
    ".pps", ".ppsx", ".ppsm",
    ".ppt", ".pptx", ".pptm",
    ".pot", ".potx", ".potm",
    ".odp", ".fodp", ".otp"
]

EXT_DOCUMENT = [
    ".doc", ".docx", ".docm",
    ".dot", ".dotx", ".dotm",
    ".odt", ".fodt", ".ott", ".rtf", ".txt",
    ".html", ".htm", ".mht", ".xml",
    ".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oxps", ".oform"
]

LANGUAGES = {
    'en': 'English',
    'hy': 'Armenian',
    'az': 'Azerbaijani',
    'eu': 'Basque',
    'be': 'Belarusian',
    'bg': 'Bulgarian',
    'ca': 'Catalan',
    'zh': 'Chinese (Simplified)',
    'zh-TW': 'Chinese (Traditional)',
    'cs': 'Czech',
    'da': 'Danish',
    'nl': 'Dutch',
    'fi': 'Finnish',
    'fr': 'French',
    'gl': 'Galego',
    'de': 'German',
    'el': 'Greek',
    'hu': 'Hungarian',
    'id': 'Indonesian',
    'it': 'Italian',
    'ja': 'Japanese',
    'ko': 'Korean',
    'lo': 'Lao',
    'lv': 'Latvian',
    'ms': 'Malay (Malaysia)',
    'no': 'Norwegian',
    'pl': 'Polish',
    'pt': 'Portuguese (Brazil)',
    'pt-PT': 'Portuguese (Portugal)',
    'ro': 'Romanian',
    'ru': 'Russian',
    'si': 'Sinhala (Sri Lanka)',
    'sk': 'Slovak',
    'sl': 'Slovenian',
    'es': 'Spanish',
    'sv': 'Swedish',
    'tr': 'Turkish',
    'uk': 'Ukrainian',
    'vi': 'Vietnamese',
    'aa-AA': 'Test Language'
}

if os.environ.get("EXAMPLE_DOMAIN"):  # generates a link for example domain
    EXAMPLE_DOMAIN = os.environ.get("EXAMPLE_DOMAIN")
if os.environ.get("DOC_SERV"):  # generates links for document server
    DOC_SERV_SITE_URL = os.environ.get("DOC_SERV")
SergeyKorneyev commented 8 months ago

@github-ljx Could you check if the issue persists with the latest versions of the Document Server and the Python example?

Leo2426 commented 1 month ago

I have the same problem with springboot

` server.version=1.9.0

server.address= server.port=4000

filesize-max=5242880 filename-max=50

files.storage=C:\documentosOffice files.storage.folder=

files.docservice.timeout=120000 files.docservice.history.postfix=-hist

files.docservice.url.site=http://localhost:80/ files.docservice.url.converter=ConvertService.ashx files.docservice.url.command=coauthoring/CommandService.ashx files.docservice.url.api=web-apps/apps/api/documents/api.js files.docservice.url.preloader=web-apps/apps/api/documents/cache-scripts.html files.docservice.url.example=

files.docservice.secret=my_jwt_secret files.docservice.header=Authorization files.docservice.token-use-for-request=true

files.docservice.verify-peer-off=true

files.docservice.languages=en:English|ar:Arabic|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|en-GB:English (United Kingdom)|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|sr-Cyrl-RS:Serbian (Cyrillic)|sr-Latn-RS:Serbian (Latin)|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language

spring.datasource.url=jdbc:h2:mem:usersdb spring.datasource.driverClassName=org.h2.Driver spring.datasource.username=sa spring.datasource.password=password spring.jpa.database-platform=org.hibernate.dialect.H2Dialect hibernate.ddl-auto spring.h2.console.enabled=true spring.h2.console.path=/h2 spring.servlet.multipart.max-file-size=5MB spring.servlet.multipart.max-request-size=5MB

url.index=/ url.converter=/converter url.editor=/editor url.track=/track url.download=/download `