Code Monkey home page Code Monkey logo

Comments (5)

olee avatar olee commented on September 25, 2024 2

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:

case MessageType.CLOSE: {
connection?.close({
code: 1000,
reason: 'provider_initiated',
})
break
}

What is the correct solution when I want to keep my websocket connection alive to use it for multiple HocuspocusProviders?

from hocuspocus.

chwzr avatar chwzr commented on September 25, 2024 1

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.

tobowers avatar tobowers commented on September 25, 2024

Re-iterating that it seems like multi-plexing might not work at all?

from hocuspocus.

janthurau avatar janthurau commented on September 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.