jabbink / PokemonGoAPI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NPEfix for PokemonGoAPI

brianpcarr opened this issue · comments

Hi jabbink

Thanks for putting together such a nice Pokemon Go bot I have had great fun playing with it. Way cool cat and mouse game with Niantic.

Recently the bot stopped working with 'empty collection'. Now I am a kotlin and gradle novice but have some experience with java, JVMs, and git. Sounded like an NPE which are very easy to find and fix (do it all the time). I did need to add some more try and catches to get the routine called by SafeSubscriber (and got the bot mostly working by adding debug console log entries on every SafeSubscribe
request (which is the equivalent of a half second pause on the thread)).

The meaningful strack trace I got had:
Caused by: java.lang.UnsupportedOperationException: Empty collection can't be reduced.
at ink.abb.pogo.api.PoGoApiImpl.handleResponse(PoGoApiImpl.kt:625)
at ink.abb.pogo.api.network.ActionQueue.sendRequests(ActionQueue.kt:204)
at ink.abb.pogo.api.network.ActionQueue.access$sendRequests(ActionQueue.kt:26)
at ink.abb.pogo.api.network.ActionQueue$1$1.invoke(ActionQueue.kt:75)
at ink.abb.pogo.api.network.ActionQueue$1$1.call(ActionQueue.kt:26)
at rx.internal.util.ActionSubscriber.onNext(ActionSubscriber.java:39)
at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:139)
... 10 more

Yippee. Simple fix to add a null check to
PoGoApiImpl.handleResponse(PoGoApiImpl.kt:625)
but wait, none of the sources I have for PoGoApiImpl has a line 625. I can see the loop where I would like to add the null check, but my builds fail in compileKotlin missing POGOProtos.

The extractIncludeProto works, but it doesn't find POGOProtos. I was able to find the source for a POGOProtos and get it to compile, but don't know where to put it (did I mention I am a gradle novice). Can you give me a suggestion on how to fix my build for the API piece?

Also, if I get a fix working should I just wrap the updates into a branch and submit a merge request. Thanks for building such a nice bot and for your help with this.
Brian

commented

The protos are in PokemonGoAPI /buildSrc/lib
POGOProtos it's a submodule and doesnt download with the zip clone the repo then do "git submodule update --init" and it will grap the protos

Thanks for the report. I'll look into it when I come around to fixing this API.

Also, if I get a fix working should I just wrap the updates into a branch and submit a merge request.

If you find it, feel free to make a pull request, yes

Hi Jabbink,

It turns out just adding a synchronize around handleResponse eliminated the pseudo NPE's. I kept adding debugger console log entries around the hangs and saw that when two requests came in within one hundredth of a second it would fail. Well duh! Simple fix to an understandable problem. The surprising thing is that it would cause most of the wonky behavior I see in the Niantic client. It would be surprising that they would use pipelined HTTP without serializing, but it would be nice if they could really fix their resource leaks and other wonkiness. The latest release is hardly usable on my budget phone. Wouldn't it be nice if they were monitoring the public open source API projects and then fixed their code so I wouldn't need a bot....

Anyway, I made up a little branch and tried to push and it was rejected, no permissions. I don't generally publish to open source projects. Is there something I should do to make a merge request? Thanks again for your help with this.
Brian

Hi Jabbink,

I remembered that open source projects often had a funky merge request process which I have used once previously. I think I submitted a proper merge request with the straight forward changes. Hope this helps. I needed to add a few sleeps in the main program to get it to work outside IntelliJ (with all my console logs) without Niantic soft bans. Those are trivial additions which anyone can do as Niantic tries to identify bots.... Wishing you all the best,
Brian

Thanks for the PR, I will look into it 👍