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  |  Other Searches  |  Print Page




Reader Comments

Jun 2, 2009 at 9:18 AM // reply »
124 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 »
7,572 Comments

@Dan,

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


Jun 2, 2009 at 10:50 AM // reply »
124 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 »
7,572 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 »
7,572 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


Jan 8, 2010 at 5:27 AM // reply »
3 Comments

hi!
Just wondering if, in the meanwhile, there is some kind of basic coldfusion wrapper for the Campaign Monitor API. Cant find anything on their site.
Ben or Mike? Any pointers?

thanks!
Bart


Jan 8, 2010 at 9:04 AM // reply »
7,572 Comments

@Bart,

I did a Google search for "Campaing Monitor cfc" and there appears to be some things you might follow up with. I have not used a wrapper personally; I've only used the "subscribe" method, so no real need for a whole CFC.


Jan 8, 2010 at 9:06 AM // reply »
7,572 Comments

@Bart,

If you can't find anything good, I could probably put together the basis of something.


Jan 8, 2010 at 9:14 AM // reply »
3 Comments

@Ben

I just approached Jon with the question how far along his CM wrapper is. If i get anything i will keep you posted.

thanks!

Bart


Post Comment  |  Ask Ben

Recent Blog Comments
Mar 20, 2010 at 12:07 PM
Drawing On The iPhone Canvas With jQuery And ColdFusion
Simply awesome. Saved my day. ... read »
Mar 20, 2010 at 9:00 AM
Building A Fixed-Position Bottom Menu Bar (ala FaceBook)
I would like to say thx for an easy way to create a bottom bar. I do have a ?. Is it possible to center the bar if i want to resize it to ex 85%. Regards Offenbach ... read »
Mar 19, 2010 at 7:26 PM
MySQL 3/4 - com.mysql.jdbc.Driver And allowMultiQueries=true
Thank you very much for this post. Adding allowMultiQueries="true" in context.xml didn't help until I added it to url as allowMultiQueries=true Good idea is to use prepared statements and it will he ... read »
Jim
Mar 19, 2010 at 4:49 PM
Nobody Puts Baby In The Corner!
Wow. This is like suddenly finding a support group for your secret shame. I'm not alone! I always liked this movie, even though it is extremely cheesy. I just wish Jennifer Grey hadn't gotten the ... read »
Mar 19, 2010 at 4:47 PM
Application.cfc OnRequest() Method Affects OnError() Arguments
@Jason and @Ben, I've been doing some CF9 refactoring on our systems and noticed an odd occurrence with onError as well. Found a way to work around my problem, but what I saw was... Background: Our ... read »
Jim
Mar 19, 2010 at 4:44 PM
Shoot 'Em Up Starring Clive Owen And Paul Giamatti
I actually enjoyed this movie quite a lot. It was different, certainly, but I think they were going for more of a Quentin Tarentino-"wow, that was weird"-vibe than an actual spoof. Once I realize ... read »
Mar 19, 2010 at 4:34 PM
An Intensive Exploration Of jQuery With Ben Nadel (Video Presentation)
Hey I guess the video is down. Is there anyway you can upload to youtube or vimeo or some other service? Greatly appreciated. ... read »
Mar 19, 2010 at 4:24 PM
ColdFusion CFPOP - My First Look
@Ben Thanks for the follow up! The root of the problem had to do with being able to trace bounced emails to specific records in a DB table. Let's say you run an email campaign and you get 1,000 bou ... read »