ueberdosis / hocuspocus

The CRDT Yjs WebSocket backend for conflict-free real-time collaboration in your app.
https://tiptap.dev/docs/hocuspocus/introduction
MIT License
1.21k stars 116 forks source link

Connection check in multiplexing #714

Open ilya2204 opened 11 months ago

ilya2204 commented 11 months ago

The problem I am facing When using multiplexing for connecting to a large number of documents via one socket the socket constantly spams with connection check messages (as I understand it is pingInterval) and this happens for each document separately.

The solution I would like Perhaps it can be done so that the connection is checked only for the main socket, and not for each document separately?

janthurau commented 11 months ago

hi @ilya2204, this shouldnt happen. I think you are seeing awareness updates, which are updated every 30 seconds per document. If you don't need awareness, you can disable it by passing awareness: null to the provider, but make sure that you have at least one provider that uses it (or otherwise receives messages before HocuspocusProviderWebsocket.messageReconnectTimeout

ilya2204 commented 11 months ago

Hello @janthurau, if this is awareness, it still doesn’t seem to make sense that when using multiplexing, each document sends its awareness once every 30 seconds? Is there a way to raise this timeout? With a large number of documents (several hundred), the socket sends messages continuously

janthurau commented 11 months ago

I dont think you can raise that as this is yjs internals (see https://docs.yjs.dev/api/about-awareness), but you can just disable it if you don't need it for some (or all) documents.

ilya2204 commented 11 months ago

Understood thanks. It's just that there are actually different parameters messageReconnectTimeout, forceSyncInterval, pingInterval, outdatedTimeout quite confusing.

ilya2204 commented 11 months ago

I could be wrong, but at first glance, if you copy Awareness class and replace the timeout with the desired one, then everything should work.

ilya2204 commented 11 months ago

@janthurau but it seems that doing ping/pong for each document on the socket, and not for the entire socket as a whole, is an overhead

ArihantBapna commented 8 months ago

@ilya2204 were you able to figure out a solution for this?