Do you want to: Ask a how-to question
Document Server version:7.4.1
Type of installation of the Document Server (docker, deb/rpm, exe):docker
OS:Window10 with docker
Python django code version:1.5.0
link: https://api.onlyoffice.com/editors/demopreview#DemoPreview
Browser version:chrome & EDGE & firefox
The code for Python example did not work, and the co-editing function was failed.
- I built the onlyOffice container for Docker on a Windows A machine and launched the embedded example webpage: ip: 5832/documents/example.
It works very well, whether accessed on computers A or B.
2.So I downloaded Python django code and planned to build a django website connect with Docker OnlyOffice, so that I could control user behavior.
- I have set up JWT, restarted OnlyOffice, and started the django website, which looks okay. Each user can log in to the django website & open & edit files.
Computer A: Accessing files from computer A (onlyoffice ) and co-editing work well.
Computer B: Accessing files from computer B (a computer on the same local area network) and co-editing failed.
One user’s editing will overwrite the content edited by another user, causing content loss.
Question:
I don’t understand why the example webpage work normally, but the django website will fail?
I found that django does not seem to support websocket by default. Is that the reason?
The source code has this configuration in settings. py: WSGI_ Application='src. wsgi. application'
I hope someone can guide me on the issue of the failure of the co-editing function on the django website.
# get file url
def getFileUri(filename, forDocumentServer, req):
host = getServerUrl(forDocumentServer, req)
curAdr = req.META['REMOTE_ADDR']
return f'{host}{settings.STATIC_URL}{curAdr}/{filename}'
the ‘curAdr’ .
When different clients access the onlyOffice server, this ‘curaddr’ is different, which will result in different initialization keys for the generated files when users open them.
Therefore, it is not considered the same file. So co-editing function cannot be implemented.
here is the key generate code:
# edit a file
def edit(request):
filename = fileUtils.getFileName(request.GET['filename'])
...
docKey = docManager.generateFileKey(filename, request)
I want to remove ’curAdr‘ in getFileUri, but I’m not sure if it will affect other performance. If anyone knowns, please help me.
Hello @zhangminong
Please see this section of our API to find out how Co-Editing works in general:
https://api.onlyoffice.com/editors/coedit
Basically, you are correct - when the same document is opened with different key it creates another editing session. To make sure that users are editing the same file, they should be able to access the document by the same document key.
If you struggle with getting it to work, I’d recommend you checking it out the test example that you have downloaded on Language-specific examples page.
I am glad to receive your reply. I have already solved the problem.
By writing a fixed uri, so that document key will be the same, the co-editting function can now be implemented normally. I think this may be a bug when different user open same file.
here is what I have done to fix the problem:
# get file url def getFileUri(filename, forDocumentServer, req): host = getServerUrl(forDocumentServer, req) curAdr = req.META['REMOTE_ADDR'] curAdr = 'for-same-key' # set the uri return f'{host}{settings.STATIC_URL}{curAdr}/{filename}'
I download the python example from your link:
I think the latest Version 1.5.1 may have the same bug.
Hello @zhangminong
By writing a fixed uri, so that document key will be the same, the co-editting function can now be implemented normally.
We are glad that you have managed the situation. However, please bear in mind, that document key generation and file url are your task as independent integrator. These are major parameters for providing the opportunity of concurrent file editing.