Comments (5)
I noticed that I need to explicitly set preserveConnection option to false to cause the connection to be closed on destroy.
On that note though, I now instead want to try to preserve the connection and even though preserveConnection is set to true, the connection is closed for a moment each time a HocuspocusProvider is destroyed.
EDIT:
Tracing this a bit more it seems that when destroying a HocuspocusProvider a CloseMessage on the document which is fine.
However, it seems this causes the server to directly close the websocket connection, even though it still might be reused:
hocuspocus/packages/server/src/MessageReceiver.ts
Lines 96 to 102 in fa2fb2e
What is the correct solution when I want to keep my websocket connection alive to use it for multiple HocuspocusProviders?
from hocuspocus.
Have the same use case here: We are doing multiplexing with one HocuspocusProviderWebsocket and multiple HocuspocusProvider. However when we want to sync to a different document we destroy the HocuspocusProvider and create a new one. This works fine, but this triggers the Websocket to close ( like @olee traced already is done by the server handling the CLOSE message).
In our case we have open an overlay in our application which shows that the HocuspocusProviderWebsocket is not connected. When we change the document this overlay is triggered for 1 second which is annoying.
I think the correct place to fix this is in the CLOSE Message - the client needs to choose whether it wants the server to close the connection or not, depending on other HocuspocusProviders registered to that HocuspocusProviderWebsocket it should not close the connection per default. What do you think?
from hocuspocus.
Re-iterating that it seems like multi-plexing might not work at all?
from hocuspocus.
the server will close the connection if no document is open, which causes issues if you want to switch documents by closing and then opening a new one. Maybe we can just add some kind of timeout before the server closes the connection, but as a workaround you should be able to just delay destroy of the provider until after a new provider attached.
from hocuspocus.
Related Issues (20)
- The server document judgment is always empty, resulting in duplicate data. HOT 2
- backend onChange undefined HOT 2
- Server crashed when webhook receives 400 status code response HOT 3
- Inaccurate document type check in onLoadDocument
- use lexical TypeError: The encoded data was not valid for encoding utf-8 HOT 1
- Updates made using openDirectConnection are not synchronizing changes across different Redis instances. HOT 9
- About the actual storage size of documents during collaborative editing HOT 8
- An authentication token is required, but you didn’t send one - but token was actually included HOT 7
- Connections to doc are possible while `onLoadDocument` is still in progress
- unsyncedChanges may get out of sync
- DirectConnection causing document state corruption HOT 3
- DirectConnection transact context not passed to document lifecycle hooks
- hocuspocus-server fails to launch in local environments via npx HOT 2
- How to implement document versioning on Hocuspocus HOT 1
- Maxdebounce causing client-id to change
- Memory leak in direct connection
- onLoadDocument hook called without document HOT 1
- Call applyUpdate duplicatedly when using hocuspocus-database HOT 1
- awareness.clientID out of sync with document.clientID HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hocuspocus.