ColdFusion 2021 CFHTTP issue – it fails every second try (or sporadically)
After a recent upgrade of ColdFusion 2016 to ColdFusion 2021 on one of the Linux servers, we noticed strange behavior. The CFHTTP call was sometimes working fine, and sometimes it was returning “Connection Failure” with the error detail of “I/O Exception: peer not authenticated”. The status code was: “Connection Failure. Status code unavailable”. This error was happening only on HTTPS calls and on about every second call. Sometimes it was happening on 60% or even 75% of calls, but in most cases, it was 50/50.
Here is what CFHTTP returns on an error in such a case:
Initially, I was thinking that maybe it is the server SSL certificate issue or load balancer issue on the destination server, but I tested on various sites, and the behavior was the same. It tended to occur more frequently on the Let’s Encrypt certified sites, though.
Finally, after testing this directly in Java, I noticed that Java itself got this issue. Since it was a fresh ColdFusion 2021 install (technically, an upgrade of CF 2016) on Ubuntu Linux, it was running on the default Java JRE version 11.0.1 shipped with ColdFusion 2021 installer.
Since the JRE download is not available for Java 11 (the JRE is prepared by the application author), I simply downloaded the newest JDK from this page: https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html
In my case, it was JDK version 11.0.15.1. I downloaded the compressed archive and unpacked it in the /opt/ColdFusion2021/jdk-11.0.15.1/ directory.
The next step was to adjust the ColdFusion configuration to use the newly downloaded JDK instead of an older JRE. To do this, I opened /opt/ColdFusion2021/cfusion/bin/jvm.config file and adjusted the “java.home” setting to look like this:
java.home=/opt/ColdFusion2021/jdk-11.0.15.1/
Lastly, I restarted the ColdFusion service by running:
> sudo service cf2021 restart
Once the ColdFusion started, the issue was gone. CFHTTP is now working properly during each call.
Notice for Windows users
The same method can be used in Windows. You can download JDK, unpack in the directory of your choice and adjust the “jvm.config” file which is located in the {cold fusion home dir}/cfusion/bin directory. Remember to restart the ColdFusion service afterward.