I keep having the following error in my Heroku PHP facebook app logs:
[app web.20] PHP Fatal error: Uncaught OAuthException: (#5) Unauthorized
source IP address\n thrown in /app/www/sdk/src/base_facebook.php on line 1238
I also noticed that the same servers keep producing this error until I recycle the processes (ie in the case above it would be web.20 and web.6 that keep failing repeatedly), but after heroku ps:restart
it would be different servers that keep failing.
Now after doing some research I noticed that people kept advising I whitelist my server IP in the Facebook App -> Advanced Settings page, meaning that Facebook keeps a list of blacklisted IPs and this is where you can allow access to them one by one.. which had me wondering why Facebook clearly encourages its users to use Heroku for its facebook apps, while at the same time black-listing its servers.
So basically:
- Heroku is Facebook's hosting partner
- Heroku provides its users with unpredictable IP addresses every time the app is recycled
- And Facebook has blacklisted many of Heroku's servers (around 1 in 10 by my count)
- So you can never be guaranteed you app is going to get access to its API for all your requests
My question is:
How are developers like me expected to configure production-ready apps in a Facebook-sponsored Heroku environment that clearly is bound to fail around a good chunk of API requests?