Residency guarantee for per-room sockets on distributed architectures #4990
-
Assuming a 10 dyno/process formation, using In the following example I'm instantiating something and assigning it to io.use((socket, next) => {
socket.data = new Cow()
next()
});
io.on('connection', () => {
socket.join(id_session)
socket.data.moo() // moooo.
}) Should I expect that this instance will survive for the duration of the connection or is there any chance of some serialising/deserialising taking place which is going to cause it to lose it's type and methods? I'm only asking about the duration of the connection, i.e if the client disconnects the state is of course lost. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi! Yes, the However, please note that if you enable Connection state recovery, then in that case the |
Beta Was this translation helpful? Give feedback.
Hi! Yes, the
socket
object is guaranteed to stay on the same Socket.IO server for the duration of the connection.However, please note that if you enable Connection state recovery, then in that case the
socket
object will indeed be serialised upon disconnection and recreated upon reconnection if the recovery is successful.