Stephan Klein
Stephan Klein

Reputation: 911

Websocket-rails and redis-rb do not restore Pub/Sub Channel on failover

I'm using websocket-rails in a synchronized cluster configuration:

Websocket-rails successfully creates a connection via redis-rb by querying Sentinel for the current master.

Also a Redis Pub / Sub Channel is created successfully to synchronize websocket events among the two Frontends:

$ redis-cli -h 192.168.1.202 -p 6379
192.168.1.202:6379> pubsub channels *
1) "websocket_rails.events"

The problem occurs on failover. After stopping the master redis node failover is successfully handled by the sentinels. After a couple of seconds they vote for a new master.

Even the FrontEnd Clients can successfully connect to the new redis master after Failover. I can successfully trigger Websocket Rails channel from rails like:

WebsocketRails["channel-id"].trigger

However the synchronisation to the other node fails. this is due the websocket redis Pub/Sub channel only existed on the old master and does not exist on the new master.

$ redis-cli -h 192.168.1.201 -p 6379
192.168.1.201:6379> pubsub channels *
(empty list or set)

Of course the channel is recreated by websocket-rails when the rails server is restarted. But this is not an option in our High Available Environment.

I wonder if this has been solved in similar environments. I kept checking the Docs of websocket-rails and redis-rb but I didnt find anything helpful. In my opinion redis behaves correctly as channels cannot be replicated.

I think the client should recreate the channel after failover but Im not even sure if this should be implemented by websocket-rails or the underlying redis-rb (or even the underlying driver) ?

Versions used:

Any help appreciated.

Attachment 1: websocket rails config:

config.log_internal_events = true 
config.standalone = false 
config.synchronize = true 
config.redis_options =  { 
:host => "mymaster",   
:sentinels => [{:host => "192.168.1.101", :port => 26379},
               {:host => "192.168.1.102", :port => 26379},
               {:host => "192.168.1.201", :port => 26379},
               {:host => "192.168.1.202", :port => 26379}],   
:role => :master}

Upvotes: 1

Views: 132

Answers (0)

Related Questions