sprotty icon indicating copy to clipboard operation
sprotty copied to clipboard

WebSocketDiagramServer 'silently' drops larger messages from client -> server

Open kdvolder opened this issue 6 years ago • 2 comments

This is probably due to some limitations in websocket implementation in the browser environment.

But we experienced that WebSocketDiagramServer silently drops messages when they go beyond a certain size. This is problematic for 'real world' diagrams. For example we found that it stopped working when we started having fairly simple graphs that have more than a dozen or so nodes. It worked fine when we only had 10 nodes or so.

Took quite a bit of guessing and trial and errror as we received no clear error messages about the packets being too large, but websockets kept getting closed shortly after the client/browser side had sent out the message that contains the 'bounds' of elements. This message never was received on the server side.

We solved this eventually by subclassing WebSocketDiagramServer and re-implementing it's sendMessage method to chop any messages larger than 4000 chars into smaller chunks and re-assembling them on the server side.

kdvolder avatar Aug 22 '19 16:08 kdvolder

FYI: Here's our custom subclass of the WebSocketDiagramServer that chops large messages into pieces.

https://github.com/kdvolder/sprotty-server-example/blob/72bbb3bc39baa121a00fd570a2bd12b493d27bd2/client/src/model.ts

kdvolder avatar Aug 22 '19 16:08 kdvolder

See also https://github.com/theia-ide/sprotty/issues/182

spoenemann avatar Aug 26 '19 14:08 spoenemann