Trying to understand the websockets by lucee here

I have some lucee code which is websockets extention added to lucee 5.3 version, in my apache setuip i enabled the proxy for the websockets as my version for apache is 2.4 and above.

So my question is regarding the virtual host file

<VirtualHost *:443>
  RewriteEngine on
  RewriteCond ${HTTP:Upgrade} websocket [NC]
  RewriteCond ${HTTP:Connection} upgrade [NC]
  RewriteRule .* "wss:/localhost:3000/$1" [P,L]
  ProxyPass / https://localhost:3000/
  ProxyPassReverse / https://localhost:3000/
  ProxyRequests off

now my website has address of:

where it is loading the localhost:3000, do i need to write localhost:3000 or my actual website name like

and in my server i have the ws folder and inside i have a chat folder and then some cfm files

so my ws folder is in


and my application.cfc is like this

component { = "websocket_chat";

    function onApplicationStart(){
        // This must be called only ONCE, so we do it here.
        WebsocketServer("/ws/chat/{channel}", new ChatListener());

and when i run it i get an error

var wschat = new WebSocket(protocol + + endpoint); on this line saying

index.cfm?username=iamtest:17 WebSocket connection to 'wss://' failed: 
Event {isTrusted: true, type: 'error', target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}
CloseEvent {isTrusted: true, wasClean: false, code: 1006, reason: '', type: 'close', …}

not sure how should i fix it, i tried everything i could, website is already running on https.

the code i tried above for websockets

also in my tomcat, i have already enabled the sessionfilter piece of code

I’ve never used websockets in production, just did some experimentscand added some examples to this forum. But I know that IIS and Apache 2.4 doesn’t support websockets out of the box. These are webservers and are meant to be used for http. Websockets simply work different than traditional http. I’ve read somewhere that you can proxypass websockets with the help of a module mod_proxy_wstunnel and then you’ll be able to proxy pass them to a websocket service. I’d try that first.

i have already tried with apache config file, but nothing seems to be working,

As per my comment on Slack, I think you might be pushing shit uphill here:

That sounds like “to be avoided” to me.

I will also answer same on the Stack Overflow question you also asked. It would be good to only ask in one place, and direct ppl in the other comms channel to the one central Q. In this case, S/O is perhaps the best place to home the question?

1 Like