How to remove CurlException in Facebook app

  1. Previous
  2. Next
  3. Recent

    1. BSNL landline bill payment using internet banking: Stepwise guide
    2. Axis Bank netbanking vs SBI netbanking: Head to Head Comparison
    3. How to Reset Transaction Password in Axis Bank netbanking
    4. Create bootable Windows 7 pen drive from ISO
    5. Understanding Domain Name: Protocol, Hostname, TLD and Subdomain
    6. Domain vs Website vs Hosting, know the difference
    7. What is wwwz, www8 in website url?
    8. 16 flop Bollywood movies that deserves watching once
    9. Article vs Blog Posts: Difference explained with example
    10. 56 little known facts about Sachin Tendulkar (the god of cricket)

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