Error on updateInventories
The program throws an exception when your itembag has more items than it can has. It happens when you have the full inventory and then get next level, the level up bonus will give you more items than your itembag can carry and the next try to update will thrown this exception
com.pokegoapi.exceptions.RemoteServerException: com.google.protobuf.InvalidProtocolBufferException: Contents of buffer are null
I think what we need is a queue system to handle all the requests so we can push requests into the queue.
Yep, already done that with my bots, will still need to rewrite all the request that we are making in the api itself, maybe doing something async with callback, we will see.
@vmarchaud I'm about to do that right now on my bot, any suggestions on the what you used? Not looking to be spoonfed code, but still a beginner programmer and this is a great way of learning on my own.
@a4andy ConcurrentLinkedQueue for sure + a custom object containing a packet to send and a callback to call with the response.
If you want more info, i'm on slack that are in the bottom of the readme with the name name. PS : you should wait for us to implement a new system into the api ^^
@a4andy Since all requests are instances of ServerRequest you could literally create a Queue that accepts ServerRequests and processes one by one them with a waiting period. However this would mean that you have to avoid using api methods. Right now I don't think there's an easier way than to just implement waiting times between actions, because trying to work around it would cost quite a bit of effort and would likely be a waste of time as it'd be implemented in the api in the coming days.
I wish I knew how to code more than I do, so I could rebuild my bot to actually work. Haha, will wait till next release.
Thanks guys, even though I probably wont get it fully working until the new system is implemented, it's still a great learning experience as I start looking into these tutorials.
@husbeard a quick fix I did was editing ServerRequest and adding a counter to only allow 3 requests max per second.
@a4andy Sorry to bother but what code did you add for this?
@RaeneDev Excuse my beginner code, this is what I came up with without needing sleep() everywhere in the main code. If there is a better way, please post it so we can all learn from it.
I have it set to 1100ms wait time, seems to work best for me.
while (true) {
// if > x seconds since last request, reset counters.
if ( (System.currentTimeMillis() - time) > 1100) {
time = System.currentTimeMillis();
current_request_count = 0;
break;
}
if (current_request_count < max_calls_allowed_per_second)
break;
// Sleep if it hasn't been 1 second yet.
Thread.sleep(100);
}
current_request_count++;
@a4andy Excuse me for my even more noobiness xD I personally don't know java at all; where would this go?
@RaeneDev goes in the beginning of the ServerRequest constructor.
@a4andy thank you, seemed I accidentally removed some code before c:
@a4andy Sorry if this is a very stupid question to ask, but could you please take a look at the code here https://github.com/SwipeX/PokeMate/ and kindly let me know where I should change or add? It is using the API from PokeGOAPI. Thanksss :3
niantic change response?
If you got this issue, you may wait for #335 to come out OR add delay between request in your software, please make an issue on the repo that you are currently using (specially for bot) and not here, since authors of these need to fix their code to send less request per seconds.
Closing since the java api isnt the issue for now but the software that are using it, we will push a release with the async stuff as soon as it will be ready.