CHTTP Connection Failure inconsistencies CF2021
- June 30, 2023
- 1 reply
- 2148 views
I am trying to create a cfhttp request to our Cisco ISE API server to retrieve endpoint devices in groups. The api is only able to return 100 devices per page and one of the groups has around 15,000 devices in it. When I run a cfhttp command for one response page on a CF page it gets a response within 300-500ms. I then tried creating a loop that would increment the page in url of the cfhttp request 10 times so in theory returning 10 pages of data or 1000 devices worth of data. When I run the cfhttp in a loop, there tends to be requests that fail with a response of connection failure: bad_record_mac.
I am running the page in a Coldfusion 2021 Update 6 server with JDK 11.0.11. This being ran on a developer build on my local machine but similar issues show on our development server which is an enterprise build.
Things I have tried:
- Downloaded cert from https site using chrome and inserted it into keystore (currently removed as it didn't seem to change anything when added)
- Added timeout of 2 seconds to cfhttp so that it would time itself out and try again quicker
- Updated JDK version to 11.0.19 (Current version installed now)
- Error detail now states Connection Exception: Connect to server.domain.org:port# failed: COnnection timed out: connect
- Created a python script that does the same call to the API server but it returns a Status 200 for larger loops without ever having any connection errors. This points me towards a setting or issue with CF Server and how it is processing the connection/request.
I did do a full run to get all the data on 20K devices (200 pages/requests) and there were around 1,500 failed connection requests before I got all the 200 correct responses back.
Here is a sample of the code I was using:
<cfsetting requestTimeOut = "600" />
<cfset groupID = '11111111111'>
<cfset successful = 0>
<cfset failed = 0>
<cfset page = 1>
<cfloop condition="#page# LTE 10">
<cftry>
<cfhttp url="https://server.domain.org/ers/config/endpoint?size=100&filter=groupId.EQ.#groupID#&page=#page#" method="get" result="resultPage" username="user" password="password" port="portNum">
<cfhttpparam type="header" name="Content-Type" value="application/json" />
<cfhttpparam type="header" name="Accept" value="application/json" />
</cfhttp>
<cfif resultPage.Statuscode EQ "200">
<cfset page = page + 1>
<cfset successful = successful + 1>
<cfelse>
<cfset failed = failed + 1>
<cfdump var="#resultPage#" >
</cfif>
<cfcatch >
<cfdump var="#cfcatch#" >
</cfcatch>
</cftry>
<cfoutput>page = #page#<br/></cfoutput>
</cfloop>
<cfoutput >
Succesful = #successful# <br/>
Failed = #failed# <br/>
</cfoutput>
Is there any other suggestions on what could possibly cause these issues? It doesn't seem to be very consistent.
