Skip to main content
Inspiring
January 15, 2021
Answered

CFHTTP works one time per restart

  • January 15, 2021
  • 5 replies
  • 1512 views

Hello All-

 

I have a strange problem with CFHTTP.

 

I am sending JSON to a server using HTTPS via CFHTTP.  My code worked successfully under CF2016 for quite a while.  I migrated servers, now using CF2018, on Windows 2019.  

 

My problem is that now I can send ONE post successfully via cfhttp, then it will no longer work.  I receive a 'Connection Failure' error after the first success.  I've repeated this exercise at least 30 times, with the same result each time.

 

This is secure, and initially I thought the problem was with my Java certificates.  I installed what I believe are the correct certs.

 

The strange part, is that it will work ONCE every time I restart CF.  I can successfully POST the JSON, and view the results on the target server, as well as receiving the appropriate response from the server.  The next POST will fail.  Every attempt after that will fail- even re-running the initial post that was successful previously.

 

But if I restart the CF service, the next POST will be successful- then all of the others will fail.

 

The fact that it does work initially, leads me to believe this is not firewally, certificates, external server, etc.  Everything I can figure out points to CF as the problem- as restarting it will 'fix' the problem for one more iteration. 

 

This is my code- the same exact code worked on my previous server:

 

  <cfhttp url="#caesdomain#/api/invoices/#caesinvoicenumber#/send" method="post" result="GoodJob" timeout="20">
      <cfhttpparam type="header" name="Authorization" value="#apikey#" >
      <cfhttpparam type="header" name="Content-Type" value="application/json" />
      <cfhttpparam type="body" value="#mailsend#">
  </cfhttp>
 
Any help would be greatly, enthusiastically, and super-super-happily appreciated!
 
(I've included a cfdump of the response upon failure.)
 
Thanks-
This topic has been closed for replies.
Correct answer karlkrist

If the cfhttp problem is still there after you update CF and Java, then we will talk some more. 🙂


BK-

My new Java version: 11.0.9+7-LTS

ColdFusion was up to date with update 10.

I tested and....it is now working!  Unfortunately the target server was also doing some troubleshooting, so I don't know whose changes fixed this.  But I am guessing the issue was on my side.

 

After lunch I will update my production server to see if this fixes things there too.

 

Thank you, thank you, thank you for pointing me in this direction.  With a brand new install of CF, I didn't think that updating the JRE would be the issue.

5 replies

Inspiring
March 23, 2021

I had a similar issue with multiple cfhttp calls that broke when migrating to cf2021.  I upgraded to java 11.10 and that fixed the issue.

 

Charlie Arehart
Community Expert
Community Expert
January 18, 2021

karlkrist, any update for us? or any response to our suggestions?

/Charlie (troubleshooter, carehart. org)
Jdsplicer
Inspiring
April 11, 2021

I am running into the same issue. Currently my cfhttp process works for the API I am calling on CF10 Enterprise version running on Windows Server 2008R2 but, on my CF2018 editon it will run once and then fail every call after that. I applied update 10 when I first noticed the issue to see if that may help but it did not. I am running ColdFusion 2018 Enterprise Version: 2018.0.10.320417 on Windows Server 2016 Standard.

 

I then did as BKBK recommended above in this thread and installed latest Java from http://adobe.com/support/coldfusion/downloads.html which was 11.0.10 and pointed my jvm.config to the new Java home directory.

 

When I dump out value for the version using 

<cfdump var="#server.system.properties.java.version#"> just to make sure, it does indeed show "11.0.10" is being used. I restarted both the server and ColdFusion service and still get this issue:

Detail: [empty string]

Message: Connection Failure: Status code unavailable

 

Another thing I tried was impoting the SSL cert for the API site into the CF Certstore using Certman but since I am able to connect at least once I don't really think that is the issue, especially since I did not need to do that step on my CF10 version which is working.

 

Here is my cfhttp call:

<cfhttp method="GET" url="https://fleet.badger-technologies.com/api/web/v1/cleansweep?from=#fullStDtTime2#&to=#fullEndDtTime2#&ahold_store_id=#TRIM(qGetMartyStores.f_storenum)#" result="MartyData" throwonerror="yes" >

<cfhttpparam type="header" name="Authorization" value="Basic #ToBase64("myuser:pwd")#"/>

<cfhttpparam type="header" name="Content-Type" value="application/json; charset=utf-8" />

</cfhttp>

 

Kind of at a loss as to what to try next. Any further ideas or did I miss a step somewhere?

 

BKBK
Community Expert
Community Expert
January 16, 2021

An idea to try: use cfhttp's clientCert and clientCertPassword attibutes. From the cfhttp documentation,

 

  • clientCert = The full path to a PKCS12 format file that contains the client certificate for the request
  • clientCertPassword = Password used to decrypt the client certificate
BKBK
Community Expert
Community Expert
January 16, 2021

@karlkrist : This is secure, and initially I thought the problem was with my Java certificates.  I installed what I believe are the correct certs.

 

I, too, thought of Java and certificates. Which Java version do you use? To see this, run:

 

<cfdump var="#server.system.properties.java.vm.version#">

 

karlkristAuthor
Inspiring
January 19, 2021

Hey BKBK!  I was wondering how to get that information!

This is the info I received when adding that dump.  (which oddly does not look like most cfdumps):

 

11.0.1+13-LTS

 

Please let me know if updating Java in some way is recommended!

Thanks-

Karl

BKBK
Community Expert
Community Expert
January 19, 2021

Ah. Java 11.0.1 is now too old for CF2018.

 

I would suggest that you:

(1) upgrade ColdFusion to the latest CF2018 update;

(2) install JAVA SE 11.0.9(LTS), typically the 64-Bit version - which you can download from http://adobe.com/support/coldfusion/downloads.html ;

(3) edit the java.home property in the system file /cfusion/bin/jvm.config to point to your Java 11.0.9 installation. For example, I have, for my CF2018 Update 10 installation on Windows:

 

java.home=C:/Program Files/Java/jdk-11.0.9

 

Charlie Arehart
Community Expert
Community Expert
January 16, 2021

Certainly odd. Please tell us what cf version this is, what update had been applied, and what jvm version it is, all indicated on the cf admin settings summary page. 

 

Also, please tell us whether there are any errors indicated in the most recent update log in the cf hf-updates folder. 

 

Finally another thing is not clear: can you confirm whether any other cfhttp calls work, whether to the same domain or another (using https and not)? 

 

/Charlie (troubleshooter, carehart. org)