How to remove CurlException in Facebook app

  1. Previous
  2. Next
  3. Recent

    1. Signs 'He' May be Cheating on You
    2. 7 Vows of Hindu Marriage - Know What 'Saat Vachans' Mean
    3. Hot IT Skills to Learn in 2016
    4. RuPay vs Visa vs Mastercard vs American Express- A Comparison
    5. What is RuPay? Everything You Need to Know About India's Domestic Payment System!
    6. Top 10 Online Portals to Find a High Paying Job in India
    7. Top Indians who Revolutionized the IT Sector in India
    8. 8 Initiatives by Narendra Modi that Could Change the Future of the Nation
    9. 8 Work-from-home Jobs for Housewives, Students, and Part timers
    10. Complete Company Registration Process in India - Explained

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