-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-loggin in if session token is close to expiring #735
Conversation
…has less than 60 seconds until expiry
I hope it will work as described 👍 |
It should do, I've done all the sanity checks, just letting it run for a while now to see if it does or not... |
This failed for some reason, and I'm now trying to work out why, so please don't merge (for now) |
sure. |
A change is needed in the pgoapi.py file. PokemonGo-Map has a different file to us. Since we use a cloned version and not our own, any idea of the best way to go about changing it? The second login is failing because the RPC endpoint is not returned for the second login. PokemonGo-Map either uses a different branch to us or a custom file (I can't tell which since they have the API folder included in their git repo and not sourced) |
Are you sure, that it can't be fixed without changes in pgoapi? For example you can try to reinit API on login, or you can try to set |
It appears the relevant changes are here. AHAAAAAAA/PokemonGo-Map@c24590e |
+1 on this. |
I tested it a little bit, and it seems like to be a working solution 👍
|
Thanks @Nihisil for the tip about resetting the API. That was a much better solution than hacking the pgoapi (which imho is broken when trying to get a new token, but there we go) :) |
Mine has been running for 4 hours now and still farming away! |
can you have the conflict fixed ? |
This works like a charm. |
Just forked the new |
This branch has conflicts that must be resolved ....... oops, duplicated review....... I need this merged badly. |
Didn't have any conflicts when I submitted it!!! :( Fine I'll go fix it :P |
Conflicts: pokemongo_bot/__init__.py
working here, thanks for this much needed fix! |
ok this has the conflicts resolved, but I've no idea what the travis build errors are for/from. |
Can you move the session expiration check to a separate function? |
I can, but I will wait until this branch is fixed before I do so, otherwise I will probably end up with more merge conflicts. Actually, I don't see much point in moving a single line if statement to a function, what is your thinking behind this? Do you want to get the session time elsewhere? Or do you mean the check and re-login? |
Well we don't like monolithic code. It just makes the code more readable and more clear. |
Ok, well, as I asked before - can you clarify what part you want? Just the call to get the remaining_time value or the whole section from the first if check down to login? |
That part. |
@MikeDX would you want to extract login logic out of the Bot class and into a worker, just like all the others? |
Waiting code isolation into separate worker to merge. |
I've moved the login check out of the work_on_cell function and moved it to its own method. This has gone from being a nice easy fix to being a real time consuming exercise 👎 |
@MikeDX I know, but it's for the best of the codebase, because we're moving towards behaviour trees and we need to make code more modular. Even though you didn't do as I suggested, that's no problem because now it's easy for me to do it myself. |
@douglascamata I'm happy for you to do it, I'm still not 100% up to speed with the whole new refactoring of the project, and having that horrible broken commit (with the teleporting) really put me off - felt like untested code was getting merged and useful code that prevent actual crashes like this was being nitpicked ;) |
@MikeDX it's more like we have too many different situations to test code :/ |
I can appreciate that. There are two times I can tell code has been merged with no apparent testing
I am sure there have been others. This fix I did originally was purely meant to satisfy a problem everyone was having - that the bot was dying after ~one hour, I wasn't prepared for the extra merge fixes (understandable) and subsequent refactoring. I want to contribute to this project and have many ideas for improvements, but if the testing / approval / merge process is as shabby as this, it's just going to be a frustrating experience, which nobody wants. |
@MikeDX it will become better when behaviour tree lands. With isolation code will become easier for us to review. Right now ppl are always trying to add too many features inside a method that they become bloated and errors are hard to spot. |
Typo in code |
Oh for goodness sake. Why the hell is it location in take_step and position in work_on_cell This codebase is just a total mess. Guess I"ll go and make a new pull request... |
* Attempting to solve the stale token issue by re-issuing if the token has less than 60 seconds until expiry * Fixes remaing time check * Reset pgoapi when rpc token is stale * Refactored session expiry check
Short Description:
Check for stale login and re-login if necessary
Fixes:
Bot working on "nothing" after a while due to session expiry