First of all, thanks for the sample! It's helping me to kickstart a project. However, if someone would run more than one replica of the socket.io server, horrible things would start happening, as instead of using a RethinkDB changefeed - which is one of the main reasons why people use RethinkDB in the first place - it just emits a message with changes which the specific server received. For example,
user 1 is connected with socket.io to server 1
user 2 posts data which get load balanced to server 2
server 2 saves data and emits a socket.io message
user 1 receives nothing
So all calls like messageService.sendCreateMessage('post', post); should be removed, and socket.io connection needs to be replaced with something like
function on_user_connected( ... ) {
r.table("posts").changes().run(rConnection).then(function(cursor) {
cursor.each(function (err, item) {
ioServer.emit('post created or deleted or updated', JSON.stringify(item, null, 2));
}
};
}
I haven't worked up a specific solution yet, but I might post a more specific sample later.
Hi,
First of all, thanks for the sample! It's helping me to kickstart a project. However, if someone would run more than one replica of the socket.io server, horrible things would start happening, as instead of using a RethinkDB changefeed - which is one of the main reasons why people use RethinkDB in the first place - it just emits a message with changes which the specific server received. For example,
So all calls like
messageService.sendCreateMessage('post', post);
should be removed, and socket.io connection needs to be replaced with something likeI haven't worked up a specific solution yet, but I might post a more specific sample later.