Collabora+Nextcloud randomly can or cannot open document

Hi. I have installed Collabora Online integrated with NextCloud (i give more details at the bottom).

While some times it works perfectly and I can open any document, at other moments it waits spinning for some seconds and then it gives an error message. I haven’t been able to identify a pattern of working or failing, although it seems to work better when i’m alone, and fail more when there are other persons using the platform.

(it means “an error occurred when connecting to the document, please retry”).

In the docker logs i see nothing interesting (there are some warnings, but they are the same when it works or it fails). But in the javascript message i see this error when it fails:

VM1572:1 Uncaught SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
    at PostMessageReadyListener (loleaflet.html?WOPISrc=https%3A%2F%2Fcloud.kaleidos.net%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F259…:14)
PostMessageReadyListener @ VM1984 loleaflet.html?WOPISrc=https%3A%2F%2Fcloud.kaleidos.net%2Fapps%2Frichdocuments%2Fwopi%2Ffile…:14

The decoded url is loleaflet.html?WOPISrc=https://cloud.kaleidos.net/apps/richdocuments/wopi/files/263_ocmltpgb8sjn&title=EBC-Informe-1.doc&lang=es&closebutton=1&revisionhistory=1

When pausing it with Chrome devtools, i get that the error occurs in this code:

// Start listening for Host_PostmessageReady message and save the
// result for future
window.WOPIpostMessageReady = false;
var PostMessageReadyListener = function(e) {
    var msg = JSON.parse(e.data);
    if (msg.MessageId === 'Host_PostmessageReady') {
        window.WOPIPostmessageReady = true;
        window.removeEventListener('message', PostMessageReadyListener, false);
    }
};
window.addEventListener('message', PostMessageReadyListener, false);

I think the statement with error is the JSON.parse(e.data). If I display the content of “e” I get

MessageEvent
    bubbles: false
    cancelBubble: false
    cancelable: false
    composed: false
    currentTarget: Window
    data: Object
        name: "started"
        target: "extension"
        timestamp: 1486037999644
        __proto__: Object
            (...)
    defaultPrevented: false
    eventPhase: 2
    isTrusted: true
    lastEventId: ""
    origin: "https://cloud.kaleidos.net"
    path: Array[1]
    ports: Array[0]
    (...)

It seems that the problem is the “data” attribute of the event is not a JSON-encoded string, but a decoded javascript object.

I cannot dig any further, I don’t understand this code, nor do i know where the event comes from, or why the data is already decoded. Also don’t know why some times it works and others fails, even with the same documents, users and browser. Any clue of how may I continue tracing the failure?

This is my system setup with more detail:

  • NextCloud 11.0.1
  • Collabora/code docker image, tag latest from 4 weeks ago (image id 833435740816)
  • Reverse proxy in the same machine with nginx as explained in https://icewind.nl/entry/collabora-online/
  • Another proxy in a fontal machine, also with nginx, that is in charge of the SSL certificates.

Thanks in advance.

bump could I have any response about this?

Thanks a lot! I really want to use nextcloud in my company, but this is stopping us :frowning:

I’m having the exact same problem… Did anybody find a solution yet?

I have a small update. I have tried to work around the failure, and so i changed the code in loleaflet/dist/loleaflet.html to avoid parsing the JSON if the data is already an object:

  window.WOPIpostMessageReady = false;
  var PostMessageReadyListener = function(e) {
    var msg;
    if (typeof(e.data) === typeof('')) {
        msg = JSON.parse(e.data);
    } else {
        msg = e.data;
    }
    if (msg.MessageId === 'Host_PostmessageReady') {
      window.WOPIPostmessageReady = true;
      window.removeEventListener('message', PostMessageReadyListener, false);
    }
  };

Now the “Unexpected token o in JSON at position 1” error is gone, but the behaviour is stange: sometimes it still freezes for around a minute, and then it shows the “connection error” message, but when I close the popup the document opens and i can work on it normally.

While the client is frozen (showing the connection spinner) it calls this URL each few seconds (although the calls resolve ok and quickly):

https://cloud.kaleidos.net/ocs/v2.php/apps/notifications/api/v2/notifications

I can’t see any relevant error message in the server logs. Only strange one is this, but it also appears when the application works ok:

wsd-00024-8043 701:10:37.529875 [ client_ws_0070 ] WRN SocketProcessor [client_ws_0070]: Connection closed.| common/IoUtil.cpp:100

Now I’m stuck again, don’t know how to continue.