Search code examples
phpnusoap

how to set maximum nuSOAP webservice access frequency in php?


Like if any client tries to access my web service more than 100 times in a minute it should throw an error message or block the client.

I searched this question and got a link [http://stackoverflow.com/questions/1251521/maximum-server-file-access-frequency][1]

But I could not get the thing properly. I want to set maximum server acces frequency. If things are not clear please do ask and help me out.

Thanks in advance :)


Solution

  • In similar circumstances, I used the following technique:

    • Each time a user access the service, log this with a timestamp

    • When a user accesses the service, check to see if they have more than X number of log entries in the last X minutes

    • If no, allow the request

    • If yes, disallow the request (perhaps with a warning why)

    • Cron job to clear the table used for logging of all entries more than X minutes old ('cos we don't care about old ones)

    If you're not passing some sort of user token with the requests, maybe use the IP.

    HTH,

    G