davidkus / triviacrack-client

Command line client and bot for Trivia Crack.
MIT License
1 stars 0 forks source link

Request to the Trivia Crack API failed. #4

Closed samcro1967 closed 4 years ago

samcro1967 commented 4 years ago

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 check_response' /usr/local/bundle/gems/triviacrack-0.2.0/lib/triviacrack/api/common.rb:37:inpost' /usr/local/bundle/gems/triviacrack-0.2.0/lib/triviacrack/api/question.rb:27:in answer_question' /code/lib/triviacrack/client/bot.rb:94:inplay_game' /code/lib/triviacrack/client/bot.rb:45:in block (2 levels) in play' /code/lib/triviacrack/client/bot.rb:45:ineach' /code/lib/triviacrack/client/bot.rb:45:in block in play' /code/lib/triviacrack/client/bot.rb:34:inloop' /code/lib/triviacrack/client/bot.rb:34:in play' bin/trivia-crack:40:inblock in start_bot' bin/trivia-crack:37:in loop' bin/trivia-crack:37:instart_bot' bin/trivia-crack:21:in bot' /usr/local/bundle/gems/thor-1.0.1/lib/thor/command.rb:27:inrun' /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:indispatch' /usr/local/bundle/gems/thor-1.0.1/lib/thor/base.rb:485:in start' bin/trivia-crack:54:in<top (required)>' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in load' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:inkernel_load' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in run' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:476:inexec' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in run' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:ininvoke_command' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in dispatch' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:30:indispatch' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in start' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:24:instart' /usr/local/bundle/gems/bundler-2.1.4/exe/bundle:46:in block in <top (required)>' /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:inwith_friendly_errors' /usr/local/bundle/gems/bundler-2.1.4/exe/bundle:34:in <top (required)>' /usr/local/bundle/bin/bundle:23:inload' /usr/local/bundle/bin/bundle:23:in `

' Restarting bot in 10 seconds...

triviacrack.log

davidkus commented 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.

samcro1967 commented 4 years ago

Here is an updated log file.

triviacrack.log

davidkus commented 4 years ago
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.

samcro1967 commented 4 years ago

Here is an updated log file after pulling the latest code this morning.

triviacrack.log

davidkus commented 4 years ago

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 .

samcro1967 commented 4 years ago

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

<TriviaCrack::Game:0x000056406ffb2ee8 @id=7910950837, @opponent=#<TriviaCrack::User:0x00005640717a4a60 @id=102425243, @username="hotty6", @facebook_id="", @facebook_name=nil, @coins=nil, @lives=nil, @max_lives=nil, @unlimited_lives=nil, @country=nil, @extra_shots=nil, @level=40, @level_points=nil, @level_progress=nil, @goal_points=nil, @level_up=nil>, @game_status=:active, @language=:en, @created=2020-03-06 12:10:09 +0000, @last_turn=2020-03-06 12:13:19 +0000, @type=:normal, @expiration_date=2020-03-08 00:13:19 +0000, @my_turn=true, @round_number=1, @is_random=true, @unread_messages=0, @status_version=11, @available_crowns=[:entertainment, :sports, :science], @questions=[#<TriviaCrack::Question:0x00005640717a5668 @id=77235741, @type=:duel, @category=:history, @text="Which war never declared a winner?", @answers=["WWI", "the Korean War", "WWII", "Three Kingdoms War"], @correct_answer=1, @media_type=:normal, @image_url=nil>, #<TriviaCrack::Question:0x00005640717a5488 @id=75623384, @type=:duel, @category=:geography, @text="What state of America suffered a severe drought during the 21st century?", @answers=["Minnesota", "New York", "Texas", "California"], @correct_answer=3, @media_type=:normal, @image_url=nil>, #<TriviaCrack::Question:0x00005640717a52a8 @id=90485217, @type=:duel, @category=:arts, @text="How is a pickle made?", @answers=["Zucchini and Olive Oil", "Zucchini And Vinegar", "Cucumber And Olive Oil", "Cucumber And Vinegar"], @correct_answer=3, @media_type=:normal, @image_url=nil>, #<TriviaCrack::Question:0x00005640717a50c8 @id=84745037, @type=:duel, @category=:sports, @text="Which Florida Football prot\u00E9g\u00E9e is famous for praising Jesus in the end zone by kneeling in prayer?", @answers=["Jameis Winston", "Tim Tebow", "Jesus De La Cruz", "Chad Henne"], @correct_answer=1, @media_type=:normal, @image_url=nil>, #<TriviaCrack::Question:0x00005640717a4ee8 @id=88637860, @type=:duel, @category=:entertainment, @text="In Harry Potter, during his conversation with Tom Riddle about Horcruxes, what number horrifies Professor Slughorn?", @answers=["7", "17", "19", "4"], @correct_answer=0, @media_type=:normal, @image_url=nil>, #<TriviaCrack::Question:0x00005640717a4d08 @id=78431375, @type=:duel, @category=:science, @text="Which of these is the atomic symbol for Gold?", @answers=["Gd", "Go", "Au", "Ph"], @correct_answer=2, @media_type=:normal, @image_url=nil>], @my_statistics=#<TriviaCrack::GameStatistics:0x000056406fdf1fa0 @correct_answers=6, @incorrect_answers=0, @questions_answered=6, @challenges_won=0, @crowns=[:history, :arts, :geography], @categories={:history=>#<TriviaCrack::CategoryStatistics:0x00005640717a4498 @category=:history, @correct=1, @incorrect=0, @worst=false>, :geography=>#<TriviaCrack::CategoryStatistics:0x00005640717a43a8 @category=:geography, @correct=1, @incorrect=0, @worst=false>, :arts=>#<TriviaCrack::CategoryStatistics:0x00005640717a42b8 @category=:arts, @correct=1, @incorrect=0, @worst=false>, :sports=>#<TriviaCrack::CategoryStatistics:0x00005640717a41c8 @category=:sports, @correct=2, @incorrect=0, @worst=false>, :science=>#<TriviaCrack::CategoryStatistics:0x00005640717a40d8 @category=:science, @correct=1, @incorrect=0, @worst=false>}>, @opponent_statistics=#<TriviaCrack::GameStatistics:0x000056406ffb3de8 @correct_answers=8, @incorrect_answers=2, @questions_answered=10, @challenges_won=0, @crowns=[:entertainment], @categories={:history=>#<TriviaCrack::CategoryStatistics:0x000056406fe95a60 @category=:history, @correct=0, @incorrect=1, @worst=true>, :geography=>#<TriviaCrack::CategoryStatistics:0x000056406ff238d8 @category=:geography, @correct=3, @incorrect=0, @worst=false>, :arts=>#<TriviaCrack::CategoryStatistics:0x000056406ff8d008 @category=:arts, @correct=1, @incorrect=0, @worst=false>, :sports=>#<TriviaCrack::CategoryStatistics:0x000056406ffa29a8 @category=:sports, @correct=0, @incorrect=1, @worst=true>, :science=>#<TriviaCrack::CategoryStatistics:0x000056406ffa0748 @category=:science, @correct=2, @incorrect=0, @worst=false>, :entertainment=>#<TriviaCrack::CategoryStatistics:0x000056406fface58 @category=:entertainment, @correct=2, @incorrect=0, @worst=false>}>>

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:inpost' /usr/local/bundle/gems/triviacrack-0.3.2/lib/triviacrack/api/question.rb:27:in answer_question' /code/lib/triviacrack/client/bot.rb:95:inplay_game' /code/lib/triviacrack/client/bot.rb:45:in block (2 levels) in play' /code/lib/triviacrack/client/bot.rb:45:ineach' /code/lib/triviacrack/client/bot.rb:45:in block in play' /code/lib/triviacrack/client/bot.rb:34:inloop' /code/lib/triviacrack/client/bot.rb:34:in play' bin/trivia-crack:42:inblock in start_bot' bin/trivia-crack:39:in loop' bin/trivia-crack:39:instart_bot' bin/trivia-crack:23:in bot' /usr/local/bundle/gems/thor-1.0.1/lib/thor/command.rb:27:inrun' /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:indispatch' /usr/local/bundle/gems/thor-1.0.1/lib/thor/base.rb:485:in start' bin/trivia-crack:59:in

' root@e5a23a55d1c6:/code#

davidkus commented 4 years ago

OK, I believe I may have solved the issue. Can you try again with the latest code?

samcro1967 commented 4 years ago

It has been running for a few hours now and I am not seeing any errors.