Skip to main content
Jdsplicer
Inspiring
April 21, 2021
Question

CFHTTP fails CF2018 Enterprise

  • April 21, 2021
  • 4 replies
  • 4540 views

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 (sometimes) 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 and I recently applied Update 11 with same results. I am running ColdFusion 2018 Enterprise Version: 2018.0.11.326016 on Windows Server 2016 Standard.

 

I then did as BKBK recommended in another post 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+8-LTS-162" is being used. I restarted both the server and ColdFusion service and still get this issue:

 

Another thing I tried was importing 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#..." 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? Attached is the cfdump.

    This topic has been closed for replies.

    4 replies

    BKBK
    Braniac
    April 26, 2021

     Is the cfhttp within a loop? If so, the client code may be making requests too frequent for the service to handle. Then a suggestion for a test would be to have a 10 second delay in between the cfhttp calls:

     

    <cfloop index="i" from="1" to="6">
    	
    <cfhttp method="GET" url="https://fleet.badger-technologies.com/api/web/v1/cleansweep?from=#fullStDtTime2#&to=#fullEndDtTime2#..." result="MartyData" throwonerror="yes" >
    
    <cfhttpparam type="header" name="Authorization" value="Basic your-auth-string-in-full"/>
    <cfhttpparam type="header" name="Content-Type" value="application/json;charset=utf-8" />
    
    <!--- Log the results to look at later (in the current folder)--->
    <cfdump var="#MartyData#" format="html" output="#expandPath('httpResults.html')#" >
    
    <!--- 10 second wait between cfhttp calls --->
    <cfset sleep(10000)>
    
    </cfhttp>
    
    </cfloop>

     

     

    Jdsplicer
    JdsplicerAuthor
    Inspiring
    April 26, 2021

    Yes, this is inside a cfloop tag. I am thinking it may be an issue at the client (somehow). I have CF2018 on 2 different 2016 Windows servers and 4 RHEL servers running websphere and they all get that same error message for this service call. The only server it works from is our CF10 windows 2012r2 server. The vendor assures me they are not whitelisting or blocking anything from our side for this call. I decided to find another external API that I could call with cfhttp to see if there us an issue with CF2018. I found a free APi call to a random joke api and it works without issue. Below is the code I used for that, looping 50 times and it connected and created 50 txt files with the response data without issue. To me this confirms that cfhttp is working as I would expect it to, at least for this unauthenticated call.

     

     

    <cfloop index="i" from="1" to="50">
        <cfoutput>#i#</cfoutput>
        <cftry>       
            <cfhttp method="GET" url="https://official-joke-api.appspot.com/random_joke" result="MartyData" throwonerror="yes">
            <cfhttpparam type="header" name="Content-Type" value="application/json; charset=utf-8" />            
            </cfhttp>
            
            <cffile action="write" file="/webnet/internet_development/SharedDev/martydata/files/MartyJSON#i#.txt" output="#MartyData.filecontent#" nameconflict="overwrite" mode="777">        
        <cfcatch>
        <cfdump var="#cfcatch#"><br />     
    <cfabort> 
        </cfcatch>
        </cftry>
    </cfloop>

     

     

    Thanks.

    BKBK
    Braniac
    April 26, 2021

    Thanks for sharing that. Did you do the test with sleep() that I suggested?

     

    One may argue that, in your (cfhttp + fileWrite) example, the fileWrite contributes a wait to the process.

    BKBK
    Braniac
    April 26, 2021

    Suggestion: in all the tests that follow, replace

     

    "Basic #ToBase64("myuser:pwd")#"

     

    with the actual authorization string. Just one thing less for us to worry about. 🙂

    Charlie Arehart
    Braniac
    April 25, 2021

    Jd, given that you are already on the latest jvm (well, as of the beginning of this week--there was newer one this week), there may be more to your problem than that. Especially since you say that this works once then fails.

     

    First, you may want to at least confirm that java 11.11 doesn't help.

     

    Second, though the code you run "worked before", I wonder if it may act differently if you urlencoded the url vars in the url of the cfhttp (using urlencodedformat).

     

    Finally, if neither helps, there's a possibility that if you installed cf10 on this same new machine, maybe you'd find that it would fail there even in cf10. Worth at least a try. And even if you might find you couldn't easily set things up to "run your app", just setup a single template to test just this one thing. Shouldn't take more than 15 mins.

     

    Woukd love to hear what you may find or think. 

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

    Charlie, hi and thank you for the suggestions. When you say Java 11.11 I assume you mean Java SE 11.0.11 as that is the latest release for the Java SE 11 Platform. If so, I went ahead and downloaded that, updated my Java virtual machine path and verifed it was using it by running the folowing:

    <cfdump var="#server.system.properties.java.vm.version#"> which displays: "Java Ver: 11.0.11+9-LTS-194" and unfortunately I still get the same result.
     
    I tried your second suggestion about "urlencoded the url vars in the url of the cfhttp (using urlencodedformat)" but that seems to fail everytime.
     
    For your thrid suggestion, unfortunately I do not have access at this time to the CF10 Enterprise software and license, I will need to see if that is something i can get from the team this week but I won't hold my breath as that was controlled by another group before I took over the CF2018 installs.
    Charlie Arehart
    Braniac
    April 25, 2021

    1) Yes, 11.0.11. Sorry, was typing quickly.

     

    2) About using urlencodedformat, what fails? Do you mean the same error as before, or about using that function? Show us what you're doing, like the other code. Maybe we'll see something to suggest. 

     

    3) Finally, as for cf10, you don't need a license. When you install cf, any version, you have a choice of putting in a license, or choosing the free developer edition, or choosing the 60-day trial--after which if you don't put in a license, it reverts to the dev edition.

     

    Lastly, as for getting the installer, you can--for any version--at a community-run site that I and others contribute to, cfmlrepo.com. 

     

    BTW, installing cf10 on a machine already running cf2018 should be no problem and have no negative on it. The cf installer will detect that the other one is running and choose unique ports for the new install. 

     

    Again, you can be done in 15 mins, so it's worth it to confirm if this is indeed the cf2018 config problem you currently are feeling it must be. And it may be, but let's rule out other possibilities first, since done easily. 

    /Charlie (troubleshooter, carehart. org)
    BKBK
    Braniac
    April 21, 2021

    You are sending data to the server by means of cfhttpparam. So I would suggest you use the Post method, rather than the Get.

    If it still doesn't work, then output the variables to see whether they are what you expect. That is:

    <cfoutput>
    	URL: https://fleet.badger-technologies.com/api/web/v1/cleansweep?from=#fullStDtTime2#&to=#fullEndDtTime2#...<br>
    	Authorization: Basic #ToBase64("myuser:pwd")#
    </cfoutput>
    Jdsplicer
    JdsplicerAuthor
    Inspiring
    April 21, 2021

    BKBK, thank you for your reposne. I am sending varibale values in the URL string along with the Authorization info but I am getting JSON data returned to me which I write to a text file. I tried your POST method but that fails with same error. I was doing the cfoutput in my cftry/cfcatch already to verify I was sending the correct values in the variables and they are correct.  As I mentioned in initial post it works one time and then fails everytime after that. I have a list of store numbers and I loop over this CFHTTP code to send the store number in one of the variables to get the JSON data back but fails everytime. Then if I wait like 20 minutyes and run it, it will work for the 1st call but then fail everytime after that again. I have been running this exact same code for almost 2 years on our CF10 Enterprise version with no issues so kinda stumped on this one with applying the updates and using newer Java version that seemed to work for others having this same issue.

    BKBK
    Braniac
    April 25, 2021

    Jdsplicer, thanks for your reply. I had another look at your first post. In thinking that you would be using httpparams to call the service, I had perhaps assumed too much. Sorry about that. As long as the httpparams are exclusively headers, you can of course use GET.

     

    quote...it works one time and then fails everytime after that. I have a list of store numbers and I loop over this CFHTTP code to send the store number in one of the variables to get the JSON data back but fails everytime. Then if I wait like 20 minutyes and run it, it will work for the 1st call but then fail everytime after that again. I have been running this exact same code for almost 2 years on our CF10 Enterprise version with no issues ...

    By @Jdsplicer

     

    Loud and clear. That's what we have to look into.

     

    To start with, could you share any log messages that you get during the failed cfhttp calls.