1

I'm running a program that sends requests to the public facebook graph API. Its multithreaded,and user-agent is set ("Mozilla/5.0...").

After 1000-10000 requests it starts getting exception:

"java.io.IOException: Server returned HTTP response code: 403 for URL = https://graph.facebook.com/etc..."

for all threads trying to get a response.
If i stop the process, and restart it, after lets say 10 minutes, it will work, but it will get the exceptions after less requests. While program is running, and getting these exceptions, I've checked the request via chrome web browser and it got the responses just fine.

I've tried switching user-agent strings on runtime, but it didn't work. Setting a global delay time to all threads when a single thread encounters the exception sometimes works, the timeout isn't consistent.

Since the ip isn't blocked, I'm having a hard time figuring how the API identifies my request and know that I'm not using an actual browser even with user agent property is defined.

Anoop B.K
  • 1,484
  • 2
  • 17
  • 31
  • In what period you do 1000-10000 requests? If it is in say 10 minutes, then I assume the app behind the API decides these requests come not from the ordinary user and are then given 403 status response. Do you use cookies with requests? – Developer Marius Žilėnas Feb 05 '15 at 08:11
  • I didn't, but it seems that setting: java.net.CookieHandler.CookieHandler.setDefault( new CookieManager( null, CookiePolicy.ACCEPT_ALL ) ); resolves the issue. – Maxim Zinger Apr 08 '15 at 22:17

0 Answers0