Git Product home page Git Product logo

Comments (5)

jondubois avatar jondubois commented on September 23, 2024

@hedgepigdaniel Yes I like this idea of transferring the full connection/state to a different host.

The current solution is to keep the reboot time as short as possible. If you send a -SIGUSR2 signal to the SC master process, it should kill all workers and they should all reboot with a fresh version of the code (if you don't have much logic in your SC workers, it should take less than a second to reboot). But if you're also waiting on other external stuff to update, then I can see how the downtime could be much longer.

Regarding missed messages, if you want to make sure that your users don't miss anything, you may want to store all messages somewhere on the backend and get a fresh 'snapshot' of the message log whenever the socket connects (or reconnects - The 'connect' event covers both cases) - This should account for any messages which may have been missed while the socket was offline. This approach is quite popular - I know Gitter.im is doing something like this.

If the reboot time is long though, the user will still get a delay before receiving the message log snapshot and also they won't be able to interact with the system (e.g. send new messages) while the reboot is happening (they will timeout from the client-side message buffer if the disconnection lasts too long) - So yes, a socket.transferConnection(...) method or similar would be really useful for those cases :) Definitely a TODO.

from socketcluster-client.

jondubois avatar jondubois commented on September 23, 2024

Note that if the reboot duration is shorter than your ackTimeout, then the SC client will buffer any messages emitted from the frontend and will send them all at once to the server when the connection is back up - So I think (in theory), you can get a seamless experience if you can keep the reboot time short (although this is not always possible to do in practice).

from socketcluster-client.

jondubois avatar jondubois commented on September 23, 2024

I'm thinking that the solution to this may require an additional layer of abstraction above the SCSocket object. SCSocket itself is an abstraction on top of plain WebSocket connections.

Maybe we should introduce a new object called SCClient (or similar) which behaves like a single SCSocket (and exposes the same methods and properties) but which could manage one or more underlying SCSocket objects at the same time (such as when doing a transfer between two hosts).

There may be use cases were someone may want to always have two or more underlying SCSocket objects connected to two or more different servers at any given time for extra resilience (at the expense of higher bandwidth usage).

SCClient would have to demultiplex the messages from multiple underlying SCSockets in order to avoid handling the same message twice. Also we don't want to accidentally publish the same message twice to two different underlying sockets.

This feels like it might need to be a new project above the current one (such that socketcluster-client would be a dependency) I think it's important not to add too much complexity to socketcluster-client.

from socketcluster-client.

jondubois avatar jondubois commented on September 23, 2024

This has already been implemented a long time ago ;p

from socketcluster-client.

hedgepigdaniel avatar hedgepigdaniel commented on September 23, 2024

Ah, good to know! Which API method can I use to transfer the connection to another socket?

from socketcluster-client.

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.