Campaign Monitor API Connection Failure With CFHTTP And GZIP Compression

Posted June 2, 2009 at 9:01 AM by Ben Nadel

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:

  • <!--- 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!



Reader Comments

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

@Dan,

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


Jun 2, 2009 at 10:50 AM // reply »
171 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 »
28 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 »
11,246 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 »
3 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 »
11,246 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 »
3 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 »
2 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 »
11,246 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 »
11,246 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 »
2 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


Aug 2, 2010 at 8:40 AM // reply »
14 Comments

The server I tried to access does not have gzip available. When I checked in the header response, it said:

Content-Encoding: deflate

(They are different aren't they?)

But that doesn't matter, what matters is your trick solved my problem too! :-)

Thanks Ben & Dan,
Khoa


Aug 2, 2010 at 2:37 PM // reply »
11,246 Comments

@Vinh,

Heck yeah! I don't fully understand the various encoding types, but I am glad this worked for you.


Dec 28, 2010 at 12:45 PM // reply »
1 Comments

Omnistar Mailer is the best email marketing software around. I increased by sales by 15 %


Jan 12, 2011 at 1:43 PM // reply »
1 Comments

Try Omnistar Mailer http://www.omnistarmailer.com because it has a cool tool for checking email in different clients.



Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
May 24, 2013 at 5:39 PM
Ask Ben: Manually Enforcing Basic HTTP Authorization In ColdFusion
@Adam Oops! My mistake! I hadn't gotten that far in my testing - I'm still baby stepping my way through the process. ... read »
May 24, 2013 at 5:13 PM
Ask Ben: Manually Enforcing Basic HTTP Authorization In ColdFusion
Hi Jason, Thanks for checking up on that, but I still stand firm on my position. :) There are actually two listLast()'s in use, and you're right that the one using a space as a delimiter is fine. ... read »
May 24, 2013 at 4:45 PM
Ask Ben: Manually Enforcing Basic HTTP Authorization In ColdFusion
@Ben I have been lurking your site for quite some time, and haven't stepped up to comment until today. Thanks for all the great info - keep it up! @Adam I believe you are mistaken... as the commen ... read »
May 24, 2013 at 11:21 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@WebManWalking, Ha ha, let's us never speak of justifying "##" notation again :P ... read »
May 24, 2013 at 11:18 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@Ben, Ah, so it was indeed how I vaguely remembered it to be: A direct assignment value = users.id[ i ] causes value to retain the sticky datatype of the query column. Although unnecessary in ... read »
May 24, 2013 at 9:11 AM
Preventing Links In Standalone iPhone Applications From Opening In Mobile Safari
@Brandon, Hi, No, I haven't been able to do that. I have just kept it as it is. ... read »
May 23, 2013 at 9:52 PM
Preventing Links In Standalone iPhone Applications From Opening In Mobile Safari
@Muhmmadibn Did you figure out a solution to launching PDFs? I am running into the same issues myself. There is no way to close the PDF or go back once you launch it. Thanks in advance! ... read »
May 23, 2013 at 6:06 PM
The Girl Who Broke My Heart, And Made Me A Better Person
Good day,ladies and gentle men, my name is Dr AMADI the great spell caster in Africa, i have help so many people for different kind of problems,who say there is no solution to problems on earth, that ... read »
InVision App - Prototyping Made Beautiful With Prototyping Tools