How to remove CurlException in Facebook app

  1. Previous
  2. Next
  3. Recent

    1. 5 Best Websites for Searching Trains in India
    2. Smartphone Operating Systems that Will make it Big in 2015
    3. Can I use Infolinks and AdSense ads together on the same page?
    4. How to Insert AdSense Ad within Post Content in WordPress (without Plugin)
    5. How to Book Newspaper Ads Online from Home
    6. 11 Killer Tips to Increase CPC of Adsense Ads
    7. How to Choose Best Web Hosting Service for Website: Best Tips
    8. What is Document Open Password for Aadhar Card
    9. How to Get Copy of Aadhar Card Online on eaadhaar.uidai.gov.in
    10. Facebook Update Publishing System Explained with PHP Code (and Ajax)


While developing a Facebook app I caught up with a problem – the ‘CurlException of Facebook app’. The reason why I quoted the phrase is because this is a very interesting exception that’s very much difficult to understand till one sees the exact error message.

Here is how the error message looks like,

remove curlexception in facebook app

The error doesn’t comes up every time an app is run. In most cases, it shows up once in a while. That’s what happened to me. The app sometimes ran fine while sometimes it didn’t.

Being an unknown problem, I looked at various sources and found that this is one of the common problems that developers face while building apps.

Why it occurs?

  1. Curl php extension must be installed in your web server. If this is absent you’ll see the exception.
  2. Next and probably the biggest reason could be the delay in loading your app. Usually an app should load/respond within 10 seconds otherwise the exception is thrown by Facebook’s php SDK.
  3. You can also see this exception when your curl functions are missing or working incorrectly. Facebook’s php SDK checks the presence of curl_init() and many other functions, and displays exception if they’re absent or working faultily.

Prevent exception from occurring

  1. If absent, install Curl library package to your php installation.
  2. Set the value of CURL_CONNECTTIMEOUT to 40-50 or more. This will allow your app to load within an extended time period. But you should know that this might run your app but this isn’t good from user perspective as they don’t like waiting such a long time for an app.

    alter curlexception timeout value remove curlexception from facebook app

  3. Another way is to keep your app lightweight. If you’re using JavaScript SDK then you’re loading an excess 170kb every-time your app runs. So avoid using the JavaScript SDK for HTTP POST/GET requests, rather use Ajax calls (in JavaScript or jQuery) for calling Graph API and FQL queries.
  4. And perhaps the best solution is to go for a better web server. Faster and responsive server makes sure your app files are loaded within time (10secs).

blog comments powered by Disqus