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>
  ServerName calendar.myworlswebsite.com  
  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
</VirtualHost>

now my website has address of: calendar.myworlswebsite.com

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

https://calendar.myworlswebsite.com/

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

/mnt/efs/home/leagues/ws/chat/index.cfm

and my application.cfc is like this

component {

    this.name = "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 + document.location.host + endpoint); on this line saying

index.cfm?username=iamtest:17 WebSocket connection to 'wss://calendar.myworlswebsite.com/ws/chat/default' failed: 
index.cfm?username=iamtest:19 
Event {isTrusted: true, type: 'error', target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}
index.cfm?username=iamtest:19 
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:

https://luceeserver.atlassian.net/browse/LDEV-3815

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