Campaign Monitor API Connection Failure With CFHTTP And GZIP Compression

Posted June 2, 2009 at 9:01 AM

Tags: ColdFusion

To manage mailing lists for clients and personal projects, I generally use Campaign Monitor. Its SOAP-based API has many different methods for subscribing, resubscribing, and unsubscribing email users to various client lists. The API interaction was great for a long time and then suddenly, a few weeks ago, I started getting "Connection Failure" on all of my ColdFusion CFHTTP requests.

 
 
 
 
 
 
SOAP-Based CFHTTP Connection Failure. 
 
 
 

I have no idea what the heck was going on. I could connect to the WSDL file just fine using the browser so I couldn't figure out why it was suddenly failing with ColdFusion's CFHTTP request. After a bit of Googling, I came across a post by Dan G. Switzer, II that discussed this very topic: CFHTTP "Connection Failures" issues with Gzip. In the post, Dan discussed that the problem comes from the fact that a connection failure in CFHTTP might be caused by the use of GZIP compression on the target server (which CFHTTP cannot handle).

I checked the compression in FireBug to confirm that this was, in fact, the case:

 
 
 
 
 
 
GZIP Compression On SOAP Web Service Request. 
 
 
 

To fix this incompatibility, Dan gave a few different options. The one I ended up going with was passing in a no-compression CFHttpParam header value with my CFHTTP request:

 Launch code in new window » Download code as text file »

  • <!--- Post SOAP data to campaign monitor. --->
  • <cfhttp
  • url="......"
  • method="get"
  • result="objSOAPPost">
  •  
  • <cfhttpparam
  • type="header"
  • name="accept-encoding"
  • value="no-compression"
  • />
  •  
  • <!--- More params go here. --->
  •  
  • </cfhttp>

Adding that CFHttpParam did the trick! Thanks Dan!

Download Code Snippet ZIP File

Post Comment  |  Ask Ben  |  Permalink  |  Other Searches  |  Print Page



Learning ColdFusion 9 - ColdFusion 9 tutorials, samples, examples, demos

Reader Comments

Jun 2, 2009 at 9:18 AM // reply »
111 Comments

You're welcome! :)

I actually just ran across another issue that I'm getting ready to blog about. This one wasn't about GZIP, but redirect rules.


Jun 2, 2009 at 9:23 AM // reply »
6,516 Comments

@Dan,

Awesome. We'll keep my eyes open for your post.


Jun 2, 2009 at 10:50 AM // reply »
111 Comments

Here's some other things to watch out for if you're using CFHTTP to call a server which has some mod_rewrite rules:

http://blog.pengoworks.com/index.cfm/2009/6/2/CFHTTP-Connection-Failures-issues-when-using-modrewrite


Jun 4, 2009 at 12:08 PM // reply »
10 Comments

I had the same issue. Fixed it the same way. Campaign Monitor confirmed they had turned on IIS compression to speed the transfers. More info on the compression issue here:

http://www.talkingtree.com/blog/index.cfm/2004/7/28/20040729


Jun 8, 2009 at 8:42 AM // reply »
6,516 Comments

@Aaron,

Seems odd that they would all of a sudden change this. Although, I guess its not a problem for most people? Maybe they sent out an "update" email that I just never saw.


Jul 13, 2009 at 7:34 AM // reply »
2 Comments

Hi Ben - On the CM forum, in a post about their ColdFusion API wrapper they recommend contacting you, but why don't they promote it? I am new to CM, so still learning my way around. Is there specific info on the API available?

Thanks for your help!

mp/m


Jul 13, 2009 at 6:25 PM // reply »
6,516 Comments

@Mike,

No problem. I don't use CM that much, but if you need any help, let me know.


Jul 14, 2009 at 11:37 AM // reply »
2 Comments

Thanks for the offer Ben. Just trying to see if they plan on (re-)releasing an API wrapper for CF. In the meantime I was able to get what I needed done - adding a checkbox to an existing form to sign up for the newsletter - without any additional code.

mp/m


Post Comment  |  Ask Ben

Recent Blog Comments
Nov 20, 2009 at 11:32 PM
Five Months Without Hungarian Notation And I'm Loving It
I've used headless camel case for years for not only ColdFusion variables, but also SQL tables and fields... pretty much everything involving code. I also subscribe to the "don't abbreviate and clea ... read »
Nov 20, 2009 at 11:00 PM
Five Months Without Hungarian Notation And I'm Loving It
@Marcel, Yeah, I always err on the side of longer but more readable variable names. As for the camel casing of CF methods and the headless camel casing of custom items, I get around this by always ... read »
Nov 20, 2009 at 10:56 PM
Five Months Without Hungarian Notation And I'm Loving It
I use the following and love it: my.namespace.MyComponents.functionMethodsOrUDF() CONSTANT_VALUES_OR_PROPERTIES One thing I always try is to CamelCaseBuiltInColdFusionFunctions() so others can tell ... read »
Nov 20, 2009 at 5:38 PM
Learning ColdFusion 8: CFImage Part I - Reading And Writing Images
Hi Ben, Great article. I've been looking around to see if ColdFusion image engine can programatically create the following "wrap around" effect: http://www.creativepro.com/article/photoshop-s-she ... read »
Nov 20, 2009 at 5:35 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
@Dave: I talked to Gert he suggested: <cfhttp method="get" url="http://{some cf website}" result="stuff" addtoken="yes" /> Note the addition of cfhttp attribute addtoken. That should persist y ... read »
Nov 20, 2009 at 5:23 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
@Todd, Ahh, gotcha, yeah that makes sense. ... read »
Nov 20, 2009 at 5:17 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
Ben, sorry if I didn't make this clear. You can make it work like that if you want, just put <cfset session.foo = 1> (and <cfset application.foo = 1>) in your OnRequestStart() and it reve ... read »