Lucee websockets for clustered environments extension using Redis PubSub


I have created an extension that allows you to use the Lucee websocket extension in a clustered environment using Redis PubSub. It is still a work in progress and is being released as beta for now until further testing is done but I wanted to get it out there for others to see and make improvements where they see fit.
I am just learning Java so there is probably a lot of room for improvement.

You can download the extension LEX file under the release tab in Github. To install the extension go to either the server or web Lucee administration pages and under the Extension -> Applications page towards the bottom there is a section for uploading a new extension. Just drop in the LEX file and click upload.

You will then need to head over to the Lucee web administration page for the host you are going to be using the extension for. Under the Services -> Event Gateway page you will want to create a new gateway instance using the Type “Lucee Redis Pub/Sub Gateway”. The Listener Component field is a relative path to your webroot where you will place a listener component CFC that will perform actions when a new message is published. The listener component should look something like this (it must implement the method onIncomingMessage(channel, data)):

component {

	public any function onIncomingMessage(channel, data) {


Your Lucee instance should now be subscribed to the channel you provided in the gateway instance configuration.

To test the Event Gateway go to a test file and add the following (change the first argument to the ID of the event gateway you created inside of the Lucee web admin):

sendGatewayMessage('test', {message:'Hello World!'})

The listener component that you created earlier with the onIncomingMessage method should receive the message you just sent. This is where you would broadcast it to all the subscribers on the websocket channel.

Make sure to follow the steps above for each additional Lucee instance you have in the cluster. After sending a message from one of the cluster instances the rest of the instances should receive the exact same message. I will be posting a video in the near future showing step by step how to setup and use the extension. I hope other people find this extension useful and I look forward to improving it.

Websocket connection between 2 lucee servers?
How to implement websocket on cluster server