Migrating from ColdFusion 2016 to Lucee

your code works.

in request settings, change request timeout to something much higher, such as 5 minutes.
Save the changes and restart lucee, flush your browsers cache, and try again, to the local connector localhost:8888 -

It works on 8888, until I push too many cookies, then it deletes the ones that were created first.

It’s when you send it out to the world on a domain, it fails

Then you need to look at your client session timeout.

in your application.cfc

turn client cookies to on
this.setClientCookies = true;

set your client cookies to something like 90 minutes
this.clientTimeout = createTimeSpan( 0, 0, 90, 0 );

I suspect that the cflocation line in cookie.cfm can get entangled in a race condition. Especially when there is a lot of cookie information to be written.

You can test this hypothesis as follows:

  1. Delete the cflocation line from cookie.cfm;
  2. Create a new CFM file, redirectToCookieDisplay.cfm. It has just one line of code, namely: <cflocation url="displaycookies.cfm">
  3. Launch the page cookie.cfm (now without cflocation), followed by the page redirectToCookieDisplay.cfm.

I have just done the following test:

  1. launch cookieCFlocationTest1.cfm;
  2. launch cookieCFlocationTest2.cfm
  3. launch cookieCFlocationTest3.cfm

cookieCFlocationTest1.cfm

<!--- Write 200 cookies --->
<cfloop index="i" from="1" to="200">
	<cfcookie name="cookie#i#" value="Value of text cookie number #i#: #createUUID()#"/>
</cfloop>

<cfdump var="#cookie#" label="Dump of cookie struct in the page cookieCFlocationTest1.cfm">

cookieCFlocationTest2.cfm
<cflocation url="cookieCFlocationTest3.cfm" addToken="false">

cookieCFlocationTest3.cfm
<cfdump var="#cookie#" label="Dump of cookie struct in the page cookieCFlocationTest3.cfm following cflocation">

All 3 pages ran as expected.

Operating System: Windows 10 Pro
Lucee version: Lucee Express 5.4.2.17

The only tweak I did was to add the attribute maxHttpHeaderSize="65536" to the default connector settings in \lucee-express-5.4.2.17\conf\server.xml:

<Connector port="8888" protocol="HTTP/1.1"  connectionTimeout="20000" redirectPort="8443"  maxHttpHeaderSize="65536"/>
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" maxHttpHeaderSize="65536"/>

cookieCFlocationTest3.pdf (335.8 KB)

I might be wrong, but I think the time out issue won’t be a thing using the solution to test by @BK_BK

I tried all three files and despite my optimism that it was going to produce a positive result, it didn’t.

I do have the two tweaks for the max header size in the server.xml

  • Windows Server 2022 - IIS 10

  • Lucee 6.1.0.243
    Blank screen returned on test1 page, view source shows it totally empty

  • Windows 10

  • ACF 2016
    Bad Request - Request Too Long
    HTTP Error 400. The size of the request headers is too long.

When you say “Blank screen returned on test1 page”, do you mean that you got a blank screen when you ran the code that I suggested in cookieCFlocationTest1.cfm ?

If so, did you first clear all the cookies, and restart Lucee, before starting the test?

For example, in between tests, I repeatedly did the following:

(1) Clear all the cookies generated in the tests. The code I used (translated to your case):
clearCookies.cfm

<cfloop index="thecookie" from="1" to="200">
    <cfcookie name="a#thecookie#b" expires="Now">
</cfloop>
All test cookies cleared

(2) Restart Lucee.

Yes, I cleared the browser cache including all cookies, rebooted the Lucee server and the browser returned a blank, empty page.

Just for clarification, this was not ran locally but externally using the domain.

OK, thanks for the update. After reviewing my code, I have improved the cookie-clearing code to:

<cfloop index="thecookie" from="1" to="200">
    <cfset structClear(cookie, "a#thecookie#b")>
</cfloop>
All test cookies cleared

You probably missed one of my questions. When you say “Blank screen returned on test1 page”, do you mean that you got a blank screen when you ran the code that I suggested in cookieCFlocationTest1.cfm ?

I have just done on ColdFusion 2023 the test (with 3 CFM files) that I suggested. The test succeeded.

To pick up on the ACF-2016 error-message, “HTTP Error 400. The size of the request headers is too long.” did you apply maxHttpHeaderSize="65536" to ACF-2016’s server.xml file?

Assuming you did, what do you get when you follow these steps:

  1. Repeat the test on ACF-2016 by again launching the CFM page.
  2. Press F12 to open Developer Tools, and F5 to refresh the page.
  3. Click on the Network tab, then on the requested CFM page.
  4. Click on the Headers tab. There you can see which header or headers have the most content.
  5. While pressing on the left mouse, scroll to select these headers, together with their content. Use CTRL-C to copy and CTRL-V to dump the contents on to a text file. Are the contents what you expect? What is the size of the text file?

I think his header values are far bigger than what he has stated.
The blank screen running the code indicates the loop may have completed but the header size was such a large value it was rejected by the sending connector.

When I initially tested his code, received a similar error until tweaking the connector and the AJP connector values.

His max header size for the initial connector should be something large, like “6553600”
This allows the internal engine connector to complete the request before it sends it to outbound / bonicode connector.

Just my thoughts.

1 Like

That is in fact what I wondered.

1 Like

Thanks for all the feedback. I’ve been away from my computer with a family matter and just got back so it’s going to take me a while to catch up with my world. I’ll do my best to run through all of this and provide some feedback within the next few days.

I cleared my cache.
Ran the CFM cookieCFlocationTest1 , the first time it worked.
It then opened the console and F5 refreshed it, the second time I get the error Bad Request - Request Too Long
I copied all of the data from the network tab which I have attached
cookie-header.txt (17.2 KB)

I’ve not made any tweaks to my CF2016 as the site works, as it’s allowing enough headers, the code I am running now is also pushing CF/IIS beyond it’s limits but I’m not concerned about pushing it further than what it will work with out of the box, which Lucee won’t as I just want to get this off the CF2016 and get it working on Lucee

At this point, I do not think this is a Lucee issue.

AFC under the hood handles long requests with its connector differently than Lucee.

Look at what you sent

First error “400” – Malformed URL -
Strict-orgigin-when-… Keep the protocol the same
context length - Size of the error

Go back to troubleshooting this first, saying it works under AFC is not useful, as I look at this and you are not giving us this tag broke here , see attached error code, instead you are stating My Application which defies standard programming practice will not work on standards based lucee. Give the community an error when you try running a tag / script function.

The other option, hire someone to go either fix your server conversion issues, or convert your code base, or both. Plenty of developers on here have moved their entire code bases to lucee, successfully.

Unfortunately it’s not an option to change the code base, there are 55 games that are using the cookies, plus the CFM code, it’s not feasible to change it.

i only have two options stay on ACF where it’s working or migrate to Lucee by trying to find out how I can make necessary changes to make it work.