PokeGOAPI-Java icon indicating copy to clipboard operation
PokeGOAPI-Java copied to clipboard

AsyncPokemonGoException: Unknown

Open jsl303 opened this issue 10 years ago • 17 comments

When I run go.getInventories().updateInventories(); or go.getMap().getCatchablePokemon(); I sometimes get this errors, and the entire thing breaks. I have to terminate and rerun. It runs fine for a while until I get the error again. I'm on commit 626145894534c4e85213eaac4116a5be519b104a. Here's the error. com.pokegoapi.exceptions.AsyncPokemonGoException: Unknown exception occurred. at com.pokegoapi.util.AsyncHelper.toBlocking(AsyncHelper.java:45) at com.pokegoapi.main.RequestHandler.sendServerRequests(RequestHandler.java:155) at com.pokegoapi.api.inventory.Inventories.updateInventories(Inventories.java:108) at com.pokegoapi.api.inventory.Inventories.updateInventories(Inventories.java:84) at PokePlay.run(PokePlay.java:220) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: com.pokegoapi.exceptions.RemoteServerException: Got a unexpected http code : 502 at rx.exceptions.Exceptions.propagate(Exceptions.java:58) at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:465) at rx.observables.BlockingObservable.first(BlockingObservable.java:168) at com.pokegoapi.util.AsyncHelper.toBlocking(AsyncHelper.java:37) ... 5 more Caused by: java.util.concurrent.ExecutionException: com.pokegoapi.exceptions.RemoteServerException: Got a unexpected http code : 502 at com.pokegoapi.main.RequestHandler$1.get(RequestHandler.java:109) at com.pokegoapi.main.RequestHandler$1.get(RequestHandler.java:86) at rx.internal.operators.OnSubscribeToObservableFuture$ToObservableFuture.call(OnSubscribeToObservableFuture.java:74) at rx.internal.operators.OnSubscribeToObservableFuture$ToObservableFuture.call(OnSubscribeToObservableFuture.java:43) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.Observable.subscribe(Observable.java:9957) at rx.Observable.subscribe(Observable.java:9924) at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:445) ... 7 more Caused by: com.pokegoapi.exceptions.RemoteServerException: Got a unexpected http code : 502 at com.pokegoapi.main.RequestHandler.internalSendServerRequests(RequestHandler.java:195) at com.pokegoapi.main.RequestHandler.run(RequestHandler.java:289) ... 1 more com.pokegoapi.exceptions.AsyncPokemonGoException: Unknown exception occurred. at com.pokegoapi.util.AsyncHelper.toBlocking(AsyncHelper.java:45) at com.pokegoapi.main.RequestHandler.sendServerRequests(RequestHandler.java:155) at com.pokegoapi.api.inventory.Inventories.updateInventories(Inventories.java:108) at com.pokegoapi.api.inventory.Inventories.updateInventories(Inventories.java:84) at com.pokegoapi.api.inventory.Inventories.(Inventories.java:74) at com.pokegoapi.api.PokemonGo.getInventories(PokemonGo.java:130) at PokePlay.login(PokePlay.java:97) at PokePlay.run(PokePlay.java:248) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: com.pokegoapi.exceptions.RemoteServerException: java.net.SocketTimeoutException: Read timed out at rx.exceptions.Exceptions.propagate(Exceptions.java:58) at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:465) at rx.observables.BlockingObservable.first(BlockingObservable.java:168) at com.pokegoapi.util.AsyncHelper.toBlocking(AsyncHelper.java:37) ... 8 more Caused by: java.util.concurrent.ExecutionException: com.pokegoapi.exceptions.RemoteServerException: java.net.SocketTimeoutException: Read timed out at com.pokegoapi.main.RequestHandler$1.get(RequestHandler.java:109) at com.pokegoapi.main.RequestHandler$1.get(RequestHandler.java:86) at rx.internal.operators.OnSubscribeToObservableFuture$ToObservableFuture.call(OnSubscribeToObservableFuture.java:74) at rx.internal.operators.OnSubscribeToObservableFuture$ToObservableFuture.call(OnSubscribeToObservableFuture.java:43) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.Observable.subscribe(Observable.java:9957) at rx.Observable.subscribe(Observable.java:9924) at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:445) ... 10 more Caused by: com.pokegoapi.exceptions.RemoteServerException: java.net.SocketTimeoutException: Read timed out at com.pokegoapi.main.RequestHandler.internalSendServerRequests(RequestHandler.java:238) at com.pokegoapi.main.RequestHandler.internalSendServerRequests(RequestHandler.java:219) at com.pokegoapi.main.RequestHandler.run(RequestHandler.java:289) ... 1 more Caused by: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.socketRead(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at sun.security.ssl.InputRecord.readFully(Unknown Source) at sun.security.ssl.InputRecord.read(Unknown Source) at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source) at sun.security.ssl.SSLSocketImpl.readDataRecord(Unknown Source) at sun.security.ssl.AppInputStream.read(Unknown Source) at okio.Okio$2.read(Okio.java:138) at okio.AsyncTimeout$2.read(AsyncTimeout.java:238) at okio.RealBufferedSource.indexOf(RealBufferedSource.java:325) at okio.RealBufferedSource.indexOf(RealBufferedSource.java:314) at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:210) at okhttp3.internal.http.Http1xStream.readResponse(Http1xStream.java:186) at okhttp3.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:127) at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:53) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170) at okhttp3.RealCall.execute(RealCall.java:60) at com.pokegoapi.main.RequestHandler.internalSendServerRequests(RequestHandler.java:193) ... 3 more com.pokegoapi.exceptions.AsyncPokemonGoException: Unknown exception occurred. at com.pokegoapi.util.AsyncHelper.toBlocking(AsyncHelper.java:45) at com.pokegoapi.api.map.Map.getMapObjects(Map.java:410) at PokePlay.run(PokePlay.java:210) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: com.pokegoapi.exceptions.RemoteServerException: java.net.SocketTimeoutException: timeout at rx.exceptions.Exceptions.propagate(Exceptions.java:58) at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:465) at rx.observables.BlockingObservable.first(BlockingObservable.java:168) at com.pokegoapi.util.AsyncHelper.toBlocking(AsyncHelper.java:37) ... 3 more Caused by: java.util.concurrent.ExecutionException: com.pokegoapi.exceptions.RemoteServerException: java.net.SocketTimeoutException: timeout at com.pokegoapi.main.RequestHandler$1.get(RequestHandler.java:109) at com.pokegoapi.main.RequestHandler$1.get(RequestHandler.java:86) at rx.internal.operators.OnSubscribeToObservableFuture$ToObservableFuture.call(OnSubscribeToObservableFuture.java:74) at rx.internal.operators.OnSubscribeToObservableFuture$ToObservableFuture.call(OnSubscribeToObservableFuture.java:43) at rx.Observable.unsafeSubscribe(Observable.java:9861) at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48) at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) at rx.Observable.subscribe(Observable.java:9957) at rx.Observable.subscribe(Observable.java:9924) at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:445) ... 5 more Caused by: com.pokegoapi.exceptions.RemoteServerException: java.net.SocketTimeoutException: timeout at com.pokegoapi.main.RequestHandler.internalSendServerRequests(RequestHandler.java:238) at com.pokegoapi.main.RequestHandler.run(RequestHandler.java:289) ... 1 more Caused by: java.net.SocketTimeoutException: timeout at okio.Okio$3.newTimeoutException(Okio.java:210) at okio.AsyncTimeout.exit(AsyncTimeout.java:288) at okio.AsyncTimeout$2.read(AsyncTimeout.java:242) at okio.RealBufferedSource.indexOf(RealBufferedSource.java:325) at okio.RealBufferedSource.indexOf(RealBufferedSource.java:314) at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:210) at okhttp3.internal.http.Http1xStream.readResponse(Http1xStream.java:186) at okhttp3.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:127) at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:53) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170) at okhttp3.RealCall.execute(RealCall.java:60) at com.pokegoapi.main.RequestHandler.internalSendServerRequests(RequestHandler.java:193) ... 2 more Caused by: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.socketRead(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at java.net.SocketInputStream.read(Unknown Source) at sun.security.ssl.InputRecord.readFully(Unknown Source) at sun.security.ssl.InputRecord.read(Unknown Source) at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source) at sun.security.ssl.SSLSocketImpl.readDataRecord(Unknown Source) at sun.security.ssl.AppInputStream.read(Unknown Source) at okio.Okio$2.read(Okio.java:138) at okio.AsyncTimeout$2.read(AsyncTimeout.java:238) ... 23 more

jsl303 avatar Aug 03 '16 19:08 jsl303

Can you post the full code where you use the methods?

FabianTerhorst avatar Aug 03 '16 19:08 FabianTerhorst

Collection stops = map.getMapObjects().getPokestops(); for (Pokestop s:stops) { if (s.inRange() & s.canLoot()) { PokestopLootResult res = s.loot(); int rsize = res.getItemsAwarded().size(); System.out.println(rsize+" items received at "+new Date().toString()+"."); } } go.getInventories().updateInventories(); if (bag.getItemsCount() > 300) discard();

On 8/3/2016 3:10 PM, Fabian Terhorst wrote:

Can you post the full code where you use the methods?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Grover-c13/PokeGOAPI-Java/issues/477#issuecomment-237340201, or mute the thread https://github.com/notifications/unsubscribe-auth/ALDSxwIWiYuy4sugF8mgPUD6uhFPSBqvks5qcOeagaJpZM4Jb_OU.

jsl303 avatar Aug 03 '16 19:08 jsl303

s.inRange() is useless. s.canLoot() also checks if it is in range.

Also posting to say that I've got the same problem.

Jari27 avatar Aug 03 '16 19:08 Jari27

Now I get this right after I log in.

go = new PokemonGo(cre, client, time);

bag = go.getInventories().getItemBag();

I have nothing between, and The second line throws the error.

On 8/3/2016 3:59 PM, Jari wrote:

s.inRange() is useless. s.canLoot() also checks if it is in range.

Also posting to say that I've got the same problem.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Grover-c13/PokeGOAPI-Java/issues/477#issuecomment-237353667, or mute the thread https://github.com/notifications/unsubscribe-auth/ALDSx7YhDTF33nZrvpK70w6IsShd6OXTks5qcPM2gaJpZM4Jb_OU.

jsl303 avatar Aug 03 '16 20:08 jsl303

Show us the stacktrace.

Also, please realize that this is for problems in THE API, not in YOUR PROJECT.

If you have troubles with programming in general, this is not the right place to ask questions.

Jari27 avatar Aug 03 '16 20:08 Jari27

Yeah, I am having the same problem using the 0.3.4 version available on jcenter. Please note that I am on Android.

EDIT : also having the same problem on the current commit https://github.com/Grover-c13/PokeGOAPI-Java/commit/626145894534c4e85213eaac4116a5be519b104a

Here is a stacktrace :

08-03 21:07:26.737 4816-4921/com.asdrubal.zubot W/System.err: com.pokegoapi.exceptions.AsyncPokemonGoException: Unknown exception occurred. 
08-03 21:07:26.737 4816-4921/com.asdrubal.zubot W/System.err:     at com.pokegoapi.util.AsyncHelper.toBlocking(AsyncHelper.java:45)
08-03 21:07:26.737 4816-4921/com.asdrubal.zubot W/System.err:     at com.pokegoapi.api.map.Map.getCatchablePokemon(Map.java:154)
08-03 21:07:26.737 4816-4921/com.asdrubal.zubot W/System.err:     at com.asdrubal.zubot.Zubot.catchCatchablePokemons(Zubot.java:349)
08-03 21:07:26.737 4816-4921/com.asdrubal.zubot W/System.err:     at com.asdrubal.zubot.Zubot.update(Zubot.java:126)
08-03 21:07:26.737 4816-4921/com.asdrubal.zubot W/System.err:     at com.asdrubal.zubot.Zubot.run(Zubot.java:176)
08-03 21:07:26.737 4816-4921/com.asdrubal.zubot W/System.err: Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: com.google.protobuf.InvalidProtocolBufferException: Contents of buffer are null
08-03 21:07:26.737 4816-4921/com.asdrubal.zubot W/System.err:     at rx.exceptions.Exceptions.propagate(Exceptions.java:58)
08-03 21:07:26.738 4816-4921/com.asdrubal.zubot W/System.err:     at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:465)
08-03 21:07:26.738 4816-4921/com.asdrubal.zubot W/System.err:     at rx.observables.BlockingObservable.first(BlockingObservable.java:168)
08-03 21:07:26.738 4816-4921/com.asdrubal.zubot W/System.err:     at com.pokegoapi.util.AsyncHelper.toBlocking(AsyncHelper.java:37)
08-03 21:07:26.738 4816-4921/com.asdrubal.zubot W/System.err:   ... 4 more

this is the code I use inside my thread :

    private void catchCatchablePokemons() throws LoginFailedException, RemoteServerException, InterruptedException {
        if (pogo!=null){
            log("Looking for catchable Pokemons...");
            List<CatchablePokemon> pks = pogo.getMap().getCatchablePokemon();
            if ((pks!=null) && (pks.size()>0)) {
                for (CatchablePokemon pk : pks) {
                    NormalEncounterResult er = (NormalEncounterResult) pk.encounterNormalPokemon();
                    if (er.wasSuccessful()) {
                        try {
                            reportCatchingPokemon(pk, er);
                            Thread.sleep(config.delayBetweenActions);
                            CatchResult catchResult = pk.catchPokemon();
                            log(catchResult.toString());
                            reportCatchPokemonResult(pk, er, catchResult);
                        }catch (Exception e){
                            e.printStackTrace();
                        }
                    }
                    Thread.sleep(2500);
                }
            }
        }
    }

hugorosario avatar Aug 03 '16 20:08 hugorosario

Sadye, It seems niantic changed their secret key for 10 minutes at 4PM EST. So this would be an API error due to the hard-coded client secret & client ID in the API.

the new app must have a second secret somewhere else in the apk.

SippieCup avatar Aug 03 '16 20:08 SippieCup

OK, seems like Niantic did something. The official app seems to be working fine with gps spoofing. Seems like they found a way to detect unauthorized access to their API.

Check : https://www.reddit.com/r/pokemongodev/comments/4w0jum/all_ptcgoogle_logins_failing_from_api/

hugorosario avatar Aug 03 '16 20:08 hugorosario

Apparently they changed the way the MapObjects data from the API is provided.

illusion12 avatar Aug 03 '16 21:08 illusion12

Looks like all API based on the first release of game are stopped working, the majority of users of the official PokemonGo App updated their app, so Niantic stopped the support of their older API. So we need to update this API to enable again data retrieve.

meher19 avatar Aug 03 '16 23:08 meher19

please refer to #486

vmarchaud avatar Aug 04 '16 12:08 vmarchaud

I'm on commit ef1f52f1f0621f94b97125975c961a8ad8129e92. I still have this problem once in a while executing commands such as: go.getInventories().updateInventories(); go.getMap().getCatchablePokemon(); Once this happens, I have to terminate and rerun.

jsl303 avatar Aug 08 '16 00:08 jsl303

Same here. I also receive the same error message on getting pokestops after logging in.

DaveBben avatar Aug 09 '16 13:08 DaveBben

Me also

KyleBoyer avatar Aug 09 '16 18:08 KyleBoyer

Same issue, I just wanted to add that everything works most of the time so I doubt that it is a programming issue with our code.

I'm assuming it had something to do with too many requests in a given period although I am throttling pokestop and pokemon scans.

behelit avatar Aug 10 '16 05:08 behelit

I have the same issue. My program does work for about 4 minutes or so without problems and it gives me this error randomly. I can loot pokestops and catch pokemons nicely until this gives me Async error. Sometimes before crashing it gives me this error when I try to catch a pokemon:

Pokemon in area:1 Encounted:SANDSHREW with cp: 113 A/CatchablePokemon: Got an error or unrecognized catch attempt A/CatchablePokemon: Proto:CatchResult(captureAward=, response=, status=CATCH_ERROR, failed=true) Attempt to catch:SANDSHREW CATCH_ERROR

Then the next pokemon crashes the program.

nacheteam avatar Aug 12 '16 08:08 nacheteam

I think I sorta found a fix. I just cached the Go object and refreshed it once every 9 minutes. I also cached the Pokestops and refreshed them every 15 seconds. So far, no async exceptions.

DaveBben avatar Aug 12 '16 11:08 DaveBben