Closed samcro1967 closed 4 years ago
I know I'm beginning to sound a bit like a broken record - but I've just pushed a new update with better logging - it should log the response from the API when the request fails now.
If you run it again after updating, it might give us better insight into why the requests are failing.
Here is an updated log file.
https://api.preguntados.com/api/users/90837342/games/7905540034/answers failed with code 400. {"message"=>"Unexpected amount of answers. Size: 1. Expected: 6 or 7", "code"=>418}
I'd be interested to see what the API is returning. I've added a --debug
flag when you start the application that will print more details, if you wouldn't mind running again. Or you could check the API directly:
curl --location --request POST 'https://api.preguntados.com/api/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "<your email>",
"password": "<your password>",
"language": "en"
}'
This will return a session
token, which you can provide to the next API request:
curl --location --request GET 'https://api.preguntados.com/api/users/90837342/games/7905540034' \
--header 'Cookie: ap_session=<session>'
It's the response to that API that I'm interested in seeing.
Here is an updated log file after pulling the latest code this morning.
You need to run with the --debug
flag, e.g. bin/trivia-crack bot -e $EMAIL -p $PASSWORD -n -f --debug
. If you are running via docker then
you'll have to update the run command in the Dockerfile to add that flag,
and then rebuild the docker image.
On Sat, Mar 7, 2020, 8:47 AM samcro1967 notifications@github.com wrote:
Here is an updated log file after pulling the latest code this morning.
triviacrack.log https://github.com/davidkus/triviacrack-client/files/4301874/triviacrack.log
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/davidkus/triviacrack-client/issues/4?email_source=notifications&email_token=ABJ33XUD46E4TMZ32NB56NTRGJGAFA5CNFSM4LBFTIN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEODZ3XI#issuecomment-596090333, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJ33XR5UYKY4NO7XRPAK4LRGJGAFANCNFSM4LBFTINQ .
Oops. I misunderstood. Sorry about that. Below is the output with the --debug flag.
root@e5a23a55d1c6:/code# bin/trivia-crack bot -e email -p password --debug Starting to play Trivia Crack as b33r1sg00d. Fetching games for b33r1sg00d... Playing game 7910950837 against hotty6.
Waiting 2 seconds before the next question...
Category : history Question : Which war never declared a winner? Answer : the Korean War
Request to https://api.preguntados.com/api/users/90837342/games/7910950837/answers failed with code 400. {"message"=>"Unexpected amount of answers. Size: 1. Expected: 6 or 7", "code"=>418}
/usr/local/bundle/gems/triviacrack-0.3.2/lib/triviacrack/api/common.rb:68:in check_response' /usr/local/bundle/gems/triviacrack-0.3.2/lib/triviacrack/api/common.rb:37:in
post'
/usr/local/bundle/gems/triviacrack-0.3.2/lib/triviacrack/api/question.rb:27:in answer_question' /code/lib/triviacrack/client/bot.rb:95:in
play_game'
/code/lib/triviacrack/client/bot.rb:45:in block (2 levels) in play' /code/lib/triviacrack/client/bot.rb:45:in
each'
/code/lib/triviacrack/client/bot.rb:45:in block in play' /code/lib/triviacrack/client/bot.rb:34:in
loop'
/code/lib/triviacrack/client/bot.rb:34:in play' bin/trivia-crack:42:in
block in start_bot'
bin/trivia-crack:39:in loop' bin/trivia-crack:39:in
start_bot'
bin/trivia-crack:23:in bot' /usr/local/bundle/gems/thor-1.0.1/lib/thor/command.rb:27:in
run'
/usr/local/bundle/gems/thor-1.0.1/lib/thor/invocation.rb:127:in invoke_command' /usr/local/bundle/gems/thor-1.0.1/lib/thor.rb:392:in
dispatch'
/usr/local/bundle/gems/thor-1.0.1/lib/thor/base.rb:485:in start' bin/trivia-crack:59:in
OK, I believe I may have solved the issue. Can you try again with the latest code?
It has been running for a few hours now and I am not seeing any errors.
After running for a few hours, the message "Request to the Trivia Crack API failed." starts appearing in the container logs. The longer the container runs, the more frequently it starts happening until it gets to the point it happens on every question. Deleting the container and re-creating it will get it running again for a few hours with no errors before it starts happening again, Below is one cycle of the error. Full log is attached from the most recent container.
Error Message Category : history Question : How long were the Crusades? Answer : 200 yearsRequest to the Trivia Crack API failed. /usr/local/bundle/gems/triviacrack-0.2.0/lib/triviacrack/api/common.rb:68:in'
Restarting bot in 10 seconds...
check_response' /usr/local/bundle/gems/triviacrack-0.2.0/lib/triviacrack/api/common.rb:37:in
post' /usr/local/bundle/gems/triviacrack-0.2.0/lib/triviacrack/api/question.rb:27:inanswer_question' /code/lib/triviacrack/client/bot.rb:94:in
play_game' /code/lib/triviacrack/client/bot.rb:45:inblock (2 levels) in play' /code/lib/triviacrack/client/bot.rb:45:in
each' /code/lib/triviacrack/client/bot.rb:45:inblock in play' /code/lib/triviacrack/client/bot.rb:34:in
loop' /code/lib/triviacrack/client/bot.rb:34:inplay' bin/trivia-crack:40:in
block in start_bot' bin/trivia-crack:37:inloop' bin/trivia-crack:37:in
start_bot' bin/trivia-crack:21:inbot' /usr/local/bundle/gems/thor-1.0.1/lib/thor/command.rb:27:in
run' /usr/local/bundle/gems/thor-1.0.1/lib/thor/invocation.rb:127:ininvoke_command' /usr/local/bundle/gems/thor-1.0.1/lib/thor.rb:392:in
dispatch' /usr/local/bundle/gems/thor-1.0.1/lib/thor/base.rb:485:instart' bin/trivia-crack:54:in
<top (required)>' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:inload' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in
kernel_load' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:inrun' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in
exec' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:inrun' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in
invoke_command' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:indispatch' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in
dispatch' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:instart' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in
start' /usr/local/bundle/gems/bundler-2.1.4/exe/bundle:46:inblock in <top (required)>' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in
with_friendly_errors' /usr/local/bundle/gems/bundler-2.1.4/exe/bundle:34:in<top (required)>' /usr/local/bundle/bin/bundle:23:in
load' /usr/local/bundle/bin/bundle:23:in `triviacrack.log