rubenmak / PokemonGo-SlackBot

Receive Slack notification whenever a Pokémon spawns near a given location
MIT License
99 stars 29 forks source link

Stops gatering info after a while #2

Open mats17 opened 8 years ago

mats17 commented 8 years ago

It seems the script stops gathering info at a while or saving it (maybe 30min or so). When looking at the output everything still seems to be running but checking the webpage show's no more Pokemon (and there are no notifications to slack). Restarting the script will intermediately show the Pokemon on the map again and push the notification to slack.

RPGReki commented 8 years ago

From what I've tried I've obsevered using -st 2 resolves the problem.

rubenmak commented 8 years ago

I don't think it fixes the problem. This seems to happen quite randomly, the connection to the Niantic servers still seems to be open but no data is received anymore. This actually might be the same issue with what you sometimes experience in the game itself, being 'jammed', stuck on a Pokéball that's not moving, empty non-interact-able Pokéstops and/or Pokémon nearby not being updated. The game works again if you restart the app, which resets the connection. A fix would be to trigger the script to reestablish the connection whenever no Pokémon have been coming in for a while, like 15 minutes. I need to find some time to take a look at it.

In case you guys can take a look at it, please let me know your findings!

mats17 commented 8 years ago

Maybe take a look at this: https://github.com/PokemonGoF/PokemonGo-Bot/pull/735 They fixed the problem there with a relogin after a while.

gregorholzmann commented 8 years ago

I'm experiencing this issue, too. After ~15 minutes the program appears to stall without any error messages.

Is it possible that the PTC servers are detecting the bot as an inactive user and unceremoniously logging it out?

markcaudill commented 8 years ago

Commenting out line 603 (@memoize) seems to fix this. My only concern is that this might raise flags on the server side. Time will tell.

rubenmak commented 8 years ago

@markcaudill : true, by removing @memoize, you actually reconnect every time you scan for new Pokémon. However, since the API endpoint remains the same, I was wondering whether you can confirm that this actually works although it remains the same?

I made a version which puts the connection in a class with a reset function. I haven't tested it thoroughly, and possibly the max_idle_time and wait_to_reconnect need to be tweaked to make sure you get a new endpoint, but also that the scanner is not waiting too long. I merged the version to develop and I'll test it tomorrow before I merge with master.

However, if you guys feel like testing, it would be great if you could pull the develop branch and share your findings!

TommyBoyee commented 8 years ago

First off thanks for starting this project! Second I've been testing the dev version off and on over the last couple of days without much luck. At this point I have not seen any messages show up in Slack. Let me what if any other info I can provide while testing.

rubenmak commented 8 years ago

Is your script still running? If not, what is the output in the commandline? If it is still running, do you see pokemon on the map on localhost:5000?

There seem to be some new types of errors coming from the servers, the scripts should probably try reconnecting in more scenario's, and the exception of wrong username password should also be changed into a new reconnect. It would help if you'd gave your output! :)

gregorholzmann commented 8 years ago

Thanks again for all your hard work on this project. I've had develop running for around a day so far without issue (using a Google login), but I'll keep testing.

TommyBoyee commented 8 years ago

Awesome, it looks like the lack of slack messages was something on my end. It has been generating them for over an hour now. For what it is worth I'm using PTC login and will continue testing.

RossS1982 commented 8 years ago

I'm pretty amateur when it comes to python (and coding in general). I have the master installed and running, but want to try to run a hot fix using the developer code referenced above. Can anyone post a step by step on how to update my existing install to leverage the above-mentioned workaround for the ~15 minute bug?

gregorholzmann commented 8 years ago

@RossS1982 You can either delete the folder with the master branch code and replace it with a .zip from here then follow the instructions on the readme again or (even better), use git to clone this repo. That way you can easily switch between master and develop branches as you see fit.

ninetaled commented 8 years ago

Holly cow this is the best thing in the world. Was able to find 2 Dragonites over the cores of 4 days that I would of never found without this program. I have been using the test branch and the auto reconnect works sometimes but most of the time I get a long error message ending with "Exception: [-] Wrong username/password" witch is weird because sometimes it works. Btw I'm using a pokeclub account.

beerlordelfbane commented 8 years ago

the initial fix worked great! However, now after about 2-3 hours I get a message repeating on a loop that says: [-]retrying_get_profile: get-profile returned no-Len profile, retrying. It continues this for indefinitely until script is killed and rerun.

rubenmak commented 8 years ago

Thanks all for sharing! May I ask whether you use google or pokeclub authentication?

I pushed to master (and develop) what I hope to be a fix for this specific issue; now the script retries getting the profile 5 times, and than waits for 60 seconds and tries to completely reconnect. Hope it helps!

Also, I disabled reconnection with PTC accounts, since it's not working as desired considering the "Wrong username/password" error (reauthenticating within some amount of time seems to give a bad JASON respone (probably some protection measure), so we'll need to find out what this amount of time is to make reconnecting work for PTC auth.

beerlordelfbane commented 8 years ago

I will definitely clone and see how the fix works! I'm actually using both, as I'm running two instances of the script and created another new account to test and see whether it would work better if only one script was connected to each account at a time. The issue does still happen though, but I will gladly try this new fix!

gregorholzmann commented 8 years ago

@rubenmak I was able to run the script all weekend long with no issue (using a google account). I would personally consider this issue closed, though it seems like the PTC might still have some trouble.

Good work!