I got it working, but had to work through a few issues. For this post, I’ll avoid talking specifically about using and/or coding for the Lucee Websockets Extension (GitHub - isapir/lucee-websocket: Enables server WebSockets for Lucee via JSR-356 compliant servlet containers (e.g. Tomcat 8, Jetty 9.1, etc.)). Prior to this post, I had websockets working in my dev environment going through Tomcat directly. My challenge was to see if I could get it running on Windows using IIS and ARR.
###Server Configuration###
-
Windows 2012 R2, IIS 8.5
-
Install the Application Request Routing module (version 3) to be used as a reverse proxy to Tomcat
Application Request Routing : The Official Microsoft IIS Site -
Install the URL Rewrite Filter to IIS
URL Rewrite : The Official Microsoft IIS Site -
Install the Websockets Role to IIS
WebSocket <webSocket> | Microsoft Learn -
Lucee v5.2.2.71, Lucee Websockets Extension, v2.0.1
###IIS Settings###
-
Configured ARR as a reverse proxy. After ARR is installed, restart IIS and you’ll see “Application Request Routing Cache” in the server home list. Click on that, and in the right pane, click on “Server Proxy Settings”. Check “Enable proxy” leaving all the default settings. Make sure “Reverse rewrite host in response headers” is checked.
-
All my websocket endpoints go through
/ws/{params}
, so I setup a URL Rewrite rule to forward those incoming websocket requests directly to Tomcat:
Pattern:^ws/([0-9a-zA-Z-_/]+)$
Rewrite to:http://{HTTP_HOST}:8888/ws/{R:1}
###Tomcat Settings###
I ran into an issue with compression using Firefox and Chrome, which I solved by disabling compression for websocket frames. I don’t completely understand this issue, and I don’t know what if there will be any overall performance issues with Tomcat/Lucee. All I know is that it worked.
Here’s where I learned about the issue:
java - Websockets on Tomcat 8 + IIS 8 with ARR 3 are not working - Stack Overflow.
Prior to making this change, websockets were being closed immediately after being opened in Firefox. In Chrome, no frames were being sent/received. So, I opened the Lucee-Tomcat Service Control, went to the Java tab, and added this to the Java Options:
-Dorg.apache.tomcat.websocket.DISABLE_BUILTIN_EXTENSIONS=true
###Other Tools###
It was helpful to turn on Failed Request Tracing:
Here are some other helpful articles: