Websocket Server Integration

Last couple of days i was thinking of a better way to integrate a WebSocket Server into Lucee.

REST(ful) as Template?
Lucee comes with a integration for Rest services. This integration has 2 limitations we are aware of and we want to address in the future:

  • debugging for invalid rest path is very hard
  • it is not possible to define a rest server on Server.cfc/Web.cfc level

But ignoring this limitation for a moment, i personally think the Rest integration in Lucee makes it easy to create REST services.

Example for Rest Server Component:

component restpath="/provider"  rest="true" {
	remote struct function getInfo(required string version restargsource="Path")
		httpmethod="GET" restpath="info/{version}" {
		return 123;

Use REST(ful) interface for websockets
Could we use the same interface we have for Rest also for websockets?
question on this, what is similar for a Rest Server and a Websocker server?
In the end it is 2 things:

  1. the protocol is different
  2. rest does use the connection for a single request/response and then they get separated again, websocket maintain a connection.

How could an integration look like?
We could do the exact same mapping we have today for rest services.
Then a component endpoint could look like this:

component restpath="/provider"  websocket="true" {

	public void function open(required struct clientInfo) {
		return 123;

	remote struct function onMessage(required message) returnformat="json|plain|wddx" {
		return 123;

	public void function onError(required struct clientInfo) {
               SystemOutput("shit happens!",true);

	public void function close(required struct clientInfo) {
		return 123;

in addition to rest services structure we could have the functions open,onError,close. The reason to have this is because this component would have a life cycle and not a single request.