Skip to content

How To: create a cluster of netty socketio servers for broadcasting messages

Pablo J. Rogina edited this page Dec 13, 2017 · 2 revisions

In order to create a cluster of netty-socketio servers for broadcasting messages across multiple servers, you can use Redisson or Hazelcast as StoreFactory. Use the following code snippet as a guide:

// Instantiate Redisson configuration
Config redissonConfig = new Config();
redissonConfig.useSingleServer().setAddress("127.0.0.1:6379");

// Instantiate Redisson connection
RedissonClient redisson = Redisson.create(redissonConfig);

// Instantiate RedissonClientStoreFactory
RedissonStoreFactory redisStoreFactory = new RedissonStoreFactory(redisson);

// Instantiate SocketIO Configuration
Configuration config = new Configuration();
config.setHostname("localhost");
config.setPort(9092);
config.setStoreFactory(redisStoreFactory);

// Instantiate SocketIO Server
SocketIOServer server = new SocketIOServer(config);

Please be aware that this approach won't provide automatic failover as stated here. Check this wiki page about failover approach.