Sudden Connection Failure

1,295 views
Skip to first unread message

Pedro Morin

unread,
Oct 23, 2013, 10:50:18 AM10/23/13
to api-d...@lists.stripe.com
I've been developing an eCommerce website using ColdFusion and Stripe for charging cards. It's still in development, so I do many test runs using the Visa 4242424242424242 which have always worked just fine. Suddenly, I'm doing the same tests I was before but I'm getting this error back from Stripe:

JSON parsing failure at character 1:'C' in Connection Failure

Any ideas on what changed when all my code is the same?

Amber Feng

unread,
Oct 24, 2013, 1:16:02 AM10/24/13
to api-d...@lists.stripe.com
Hi Pedro,

Sorry for the late reply here.

I'm not sure I've ever seen that particular failure from Stripe before
-- it looks like that may be something on your side (unless you can
point me to the offending log in
https://manage.stripe.com/logs?success=false&method=not_get)?

Amber
> --
> You received this message because you are subscribed to the Google Groups
> "Stripe API Announcements and Discussion" group.
> To post to this group, send email to api-d...@lists.stripe.com.
> Visit this group at
> http://groups.google.com/a/lists.stripe.com/group/api-discuss/.
>
> To unsubscribe from this group and stop receiving emails from it, send an
> email to api-discuss...@lists.stripe.com.

Vladimir Andrijevik

unread,
Oct 24, 2013, 3:14:57 AM10/24/13
to api-d...@lists.stripe.com
I think what may have happened here was a temporary network connectivity issue, with the network library being used returning a Connection Failure error instead of the JSON body from Stripe.

Since Connection Failure (without quotes) is not a valid JSON response body, and the code assumed a JSON response, the parser choked on the first character.

Pedro, you likely need to guard against network errors (and other non-Stripe exceptions) in your code before trying to parse the body as JSON in your code.

Hope that helps!

Cheers,
Vlad

Eric Moore

unread,
Dec 6, 2013, 8:37:13 PM12/6/13
to api-d...@lists.stripe.com, pedro.m...@gmail.com
Pedro, did you find a solution to this? I'm having a similar problem and I think there was a change to how Stripe handles their gateway. It can't parse JSON if no JSON response is given back.

Thanks, Eric 

Andy Brody

unread,
Dec 6, 2013, 8:41:59 PM12/6/13
to api-d...@lists.stripe.com
Hi Eric and Pedro,

Are you both using ColdFusion? What library are you using to connect
to Stripe? "Connection Failure" sounds like a message from one of the
underlying libraries, not anything that Stripe would send back.

Best wishes,
Andy
> --
> You received this message because you are subscribed to the Google Groups "Stripe API Discussion" group.

Eric Moore

unread,
Dec 6, 2013, 8:58:21 PM12/6/13
to api-d...@lists.stripe.com
Thanks for the response Andy. 

That's the error I got when I tried to deserialize the JSON return values. Using <cfset response = deserializeJSON( charge.fileContent ) />

I'm using a very simple cfhttp to post the data at stripe:

<cfhttp result="charge" method="post" url="https://api.stripe.com/v1/charges" username="sk_test_WHATEVER" password="">
  <cfhttpparam type="formfield" name="amount" value="#(form.amount * 100)#" />
  <cfhttpparam type="formfield" name="currency" value="usd" />
  <cfhttpparam type="formfield" name="card" value="#form.stripeToken#" />
  <cfhttpparam type="formfield" name="description" value="Order Test" />
</cfhttp>

This had been working fine for several months. Now I'm getting no charges in the test or live dashboard with Stripe. Now I am not getting any response of any kind from the api gateway. If there is a connection failure, the response is empty and when you deserialize it, coldfusion fails. In production version I have this wrapped in a cftry so it errors gracefully and gives a generic error response that I set as "There was an unexpected error during the processing of your purchase. The error has been logged an our team is looking into it." Before it would give any of the response from Stripe. For example like "Credit Card Declined" etc. Now there is nothing. Which leads me to believe there is a gateway access problem. 

Eric Moore

unread,
Dec 7, 2013, 1:10:42 PM12/7/13
to api-d...@lists.stripe.com
Apparently there is an issue with the security provider/authenticator used by ColdFusion too check if public certs are valid. If the cert can't be validated, the connection bombs and you can't connect to the server. This issue happens with CF9 Enterprise as far as I know. It's not limited to Stripe as it can happen with a lot of sites that use SSL. I used Raymond Camden's fix opposed to importing certs into coldfusion's store (which may or may not fix your problem).


Andy Brody

unread,
Dec 10, 2013, 7:29:47 PM12/10/13
to api-d...@lists.stripe.com
Hi Eric,

I'm glad you were able to track down the problem! By the way, if
you're looking for a library to use for interacting with Stripe, there
are a few third-party ColdFusion libraries that you might find useful.
https://github.com/ghidinelli/cfpayment advertises that it "Eliminates
writing boilerplate code and handling esoteric CFHTTP errors that only
seem to happen in production." You can find a few others at
https://stripe.com/docs/libraries#third-party.

Best wishes,
Andy
Reply all
Reply to author
Forward
0 new messages