MySQL hosting error "HTTP/1.1 403 Forbidden"

Hey,
Bought hosting from hostinger.com, i have a MySQL database setup there.
When i call POST requests from my unity app (lets say once per 5sec), its ok.
But my app needs to write more often than that, so when i let my app run, it writes data for 3sec, and then i keep getting error to my debug log saying “HTTP/1.1 403 Forbidden”.
I do not have a .htaccess in my public_html, i dont have anything else in there except my .php files.

This is how i call POST in my C# script:

 static public IEnumerator somefunction()
    {
        WWWForm form = new WWWForm();
        form.AddField("something",  "something");

        using (UnityWebRequest www = UnityWebRequest.Post("https://url/myphp.php", form))
        {
            yield return www.SendWebRequest();

            if (www.result != UnityWebRequest.Result.Success)
            {
                Debug.Log(www.error);
            }
        }
    }

So it works if done at 5 sec intervals, but fails with 3 seconds? You mentioned “writes data for 3sec”, can you elaborate? Is that 3 second duration, or an interval? A REST API would probably be more performant

Why don’t you check server-side logs? Webserver logs, I mean.

Also, you can troubleshoot by using Charles Proxy or Fiddler https://support.unity.com/hc/en-us/articles/115002917683-Using-Charles-Proxy-with-Unity

hey, i log errors to error_log.txt via .htaccess, nothing comes up there.

hey, i have a server app which sets values to database, then another app thats the main game, i can run the server alone (it does ALOT of writing, im talking about probably 20 writes per second, but when i start my main game, it does some reading/writing too, then i start getting the 403 error…
it goes both ways, if i run the main game all alone, all fine, but if i start my server on the side, i start getting errors.
i feel like i am “flooding” it too much? like sending insane amounts of requests?
charles i downloaded and checked, was like 1000 requests in 48sec to my database url, idk how to debug it tho yet.

Sorry, 20 writes per second? Why, what is changing that frequently in the game? And what do you mean “start my server on the side”. Is this a multiplayer game, why a server at all if not? I Please provide the Charles capture comparing a good vs bad request. That will pinpoint the issue. Make sure you are not writing any data from your game in Update() or FixedUpdate()

Hey,
thanks for all your help & effort, but i think the real problem is the way i handle my writing to database, this is not a good thing to do that many writes lol :smile: i am sure it is just flooding from all the damn GETS and POSTS im doing…

It is also possible that if there are too many requests from an IP address in a short time, a DDoS protection on the server denies the connection.

If you want to build a robust backend for your game rather use something like Azure Playfab which is free for up to 100 000 users. And if you definately need a MySQL database you can add one too and talk to it from Azure Functions which can be called from Playfab.

Allowing the client to post to a web page that talks to a database is not a very efficient, nor secure way to go about it.