many HTTP requests

Hello,

I’m developing something like an auto-QA system for my game. Using triggers and function calls placed within behavior code, I call a function which does a WWW request. This request sends certain data to a php script running on a web server which saves that data to a database. This way, when we let lots of people play our game, we can collect data every time they play about whatever we want.

Obviously I have to pick rare enough behaviors (not, for example, “player jumped”) that I won’t hose my server, but just for the sake of testing, I’ve tried to spam my server to see what happens.

What happens is mostly good. For the most part, my requests go through, and the data shows up in the db. However, every once in a while (and I think this is mostly when a lot of requests come really fast) the request will go through, but the data will not. I know this because I have new rows in my table in my database, but their values are 0 or “”.

Is there a good way to schedule these WWW requests? I was thinking of bundling them, say 5 requests at a time, but I’m not sure if that will solve my problem.

Has anyone else been seeing this?

-scone

Have you been able to track this down to the data not being sent by Unity or not being processed correctly by the PHP script?

Bundling requests from a single player would almost certainly be more efficient. A significant part of the time taken is in setting up the request and there is also some data overhead with HTTP headers, etc. Sending several data records together should avoid some of this, especially if the data is just a few small values each time. This would probably reduce the load on the server quite a bit, too.

Sorry for the huge lag time here. Other projects took priority and this got put on the back burner.

Yeah like I said I was thinking about bundling. I haven’t explicitly ruled out the PHP script, but it’s the simplest thing in the world (loop through POST array, forming an insert query based on the keys/values) and works for most of the requests.

Is there another way to establish a connection with the server? Some sort of socket class?

I think with standard PHP being based around requests, sending a POST from Unity is probably the best way to go if it can be made to work. If you can post the PHP script (however simple) and the part of the code you are using to submit the forms, then it might offer a clue about what is going wrong.

I had some problems when using lots of WWW calls, changed to socket, see this topic http://forum.unity3d.com/threads/72334-problems-with-WWW

Good advice, I actually came to the same point when trying to make requests from the editor (where the WWW class is inaccessible)

It works great!