SOLR Error - org.apache.commons.httpclient.NoHttpResponseException
Copy link to clipboard
Copied
Hi All,
I'm hoping someone can point me in the right direction. Ever since upgrading from ColdFusion 10 to ColdFusion 11 I have been seeing this error intermittently throughout the day. The server that it's happening on is averaging between 5-10 requests per second so the traffic is very low.
Here is the exact error message from ColdFusion. I get an email every time there is an error so I can be alerted.
There was a problem while attempting to perform a search. org.apache.commons.httpclient.NoHttpResponseException: The server localhost failed to respond <br>The error occurred on line [XXX].
Once I see the error I try the web page and it works every time so I can't duplicate it.
Has anyone experienced this random issue? Is there anything I can try to fix it?
Copy link to clipboard
Copied
Anyone have any ideas?
Copy link to clipboard
Copied
Intermittent errors are much more difficult to troubleshoot. But no one can help unless you provide some of your code (specifically the line where the error is occurring, and the surrounding lines.) It could be something very simple.
V/r,
^_^
Copy link to clipboard
Copied
No problem. Here is the code that runs. Basically what happens is I prepare the criteria for SOLR in one fashion, and if there are no results, relax the rules a bit and run a second search. If there are still no results, I run a third query with cfquery to try and get some results for the customer. The error can occur on any of the cfsearch lines below but they seem to occur more on the first getNavigations one.
<!--- Set search criteria --->
<cfset SearchCriteria = Trim(REReplaceNoCase(URL.criteria,"[^a-zA-Z0-9_ ]","","ALL"))>
<cfset SearchCriteria = REReplaceNoCase(SearchCriteria," AND "," ","ALL")><!--- Replace AND operator with a single space --->
<cfset SearchCriteria = REReplaceNoCase(SearchCriteria," OR "," ","ALL")><!--- Replace OR operator with a single space --->
<cfset SearchCriteria = REReplaceNoCase(SearchCriteria," NOT "," ","ALL")><!--- Replace NOT operator with a single space --->
<cfset SearchCriteria = REReplaceNoCase(SearchCriteria,"\s+"," ","ALL")><!--- Replace any number of spaces with a single space --->
<cfif Len(Trim(SearchCriteria))>
<!--- Set search criteria for solr --->
<cfset SearchCriteriaForSolr = "">
<cfloop index="i" list="#SearchCriteria#" delimiters=" ">
<cfset SearchCriteriaForSolr = SearchCriteriaForSolr & "+#i# ">
</cfloop>
<!--- Get products --->
<cfsearch name="getProducts" collection="product" criteria="#Trim(SearchCriteriaForSolr)#">
<cfif NOT getProducts.RecordCount>
<!--- Set search criteria for solr --->
<cfset SearchCriteriaForSolr = "">
<cfset ThisRow = 1>
<cfloop index="i" list="#SearchCriteria#" delimiters=" ">
<cfif ThisRow EQ 1>
<cfset SearchCriteriaForSolr = SearchCriteriaForSolr & "+#i# ">
<cfelse>
<cfset SearchCriteriaForSolr = SearchCriteriaForSolr & "#i# ">
</cfif>
<cfset ThisRow = ThisRow + 1>
</cfloop>
<!--- Get products --->
<cfsearch name="getProducts" collection="product" criteria="#SearchCriteriaForSolr#">
<cfif NOT getProducts.RecordCount>
<!--- Run a third query here with a LIKE statement --->
</cfif>
</cfif>
<!--- Get navigations --->
<cfsearch name="getNavigations" collection="navigation" criteria="#SearchCriteriaForSolr#">
<cfif NOT getNavigations.RecordCount>
<!--- Set search criteria for solr --->
<cfset SearchCriteriaForSolr = "">
<cfset ThisRow = 1>
<cfloop index="i" list="#SearchCriteria#" delimiters=" ">
<cfif ThisRow EQ 1>
<cfset SearchCriteriaForSolr = SearchCriteriaForSolr & "+#i# ">
<cfelse>
<cfset SearchCriteriaForSolr = SearchCriteriaForSolr & "#i# ">
</cfif>
<cfset ThisRow = ThisRow + 1>
</cfloop>
<!--- Get navigations --->
<cfsearch name="getNavigations" collection="navigation" criteria="#SearchCriteriaForSolr#">
<cfif NOT getNavigations.RecordCount>
<!--- Run a third query here with a LIKE statement --->
</cfif>
</cfif>
<cfelse>
<cfset getProducts.RecordCount = 0>
<cfset getNavigations.RecordCount = 0>
</cfif>
Copy link to clipboard
Copied
Well, all your code seems to be fine, although I personally wouldn't add a '+' to the beginning of every word (Solr is good for phrase searches, too.) Plus, I think you could use RegEx to do that instead of looping. But, I digress (and boy is that painful - ba dum bump tssss!)
If the issue is intermittent, then I think that the SO link I offered in my earlier post might contain a solution. It's also possible that CF server, itself, is to blame (sometimes it seems like it takes a long time for certain page loads/refreshes to complete.)
V/r,
^_^
Copy link to clipboard
Copied
I did some Googling (I can't believe that is a VERB, now) and found some things that I hope will help.
http://hc.apache.org/httpclient-3.x/exception-handling.html
http://stackoverflow.com/questions/10558791/apache-httpclient-interim-error-nohttpresponseexception
HTH,
^_^

