pmariglia / showdown

A Pokemon Showdown Battle Bot written in Python
GNU General Public License v3.0
260 stars 178 forks source link

error while running. #199

Open xumical opened 3 months ago

xumical commented 3 months ago

[ERROR] Traceback (most recent call last): File "/root/showdown/run.py", line 103, in asyncio.run(showdown()) File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/root/showdown/run.py", line 87, in showdown winner = await pokemon_battle(ps_websocket_client, ShowdownConfig.pokemon_mode) File "/root/showdown/showdown/run_battle.py", line 181, in pokemon_battle battle = await start_battle(ps_websocket_client, pokemon_battle_type) File "/root/showdown/showdown/run_battle.py", line 170, in start_battle battle = await start_random_battle(ps_websocket_client, pokemon_battle_type) File "/root/showdown/showdown/run_battle.py", line 119, in start_random_battle battle, opponent_id, user_json = await initialize_battle_with_tag(ps_websocket_client) File "/root/showdown/showdown/run_battle.py", line 79, in initialize_battle_with_tag battle_tag, opponent_name = await get_battle_tag_and_opponent(ps_websocket_client) File "/root/showdown/showdown/run_battle.py", line 66, in get_battle_tag_and_opponent msg = await ps_websocket_client.receive_message() File "/root/showdown/showdown/websocket_client.py", line 45, in receive_message message = await self.websocket.recv() File "/usr/local/lib/python3.10/dist-packages/websockets/legacy/protocol.py", line 553, in recv await self.ensure_open() File "/usr/local/lib/python3.10/dist-packages/websockets/legacy/protocol.py", line 930, in ensure_open raise self.connection_closed_exc() websockets.exceptions.ConnectionClosedOK: received 1000 (OK) Normal closure; then sent 1000 (OK) Normal closure

Traceback (most recent call last): File "/root/showdown/run.py", line 103, in asyncio.run(showdown()) File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/root/showdown/run.py", line 87, in showdown winner = await pokemon_battle(ps_websocket_client, ShowdownConfig.pokemon_mode) File "/root/showdown/showdown/run_battle.py", line 181, in pokemon_battle battle = await start_battle(ps_websocket_client, pokemon_battle_type) File "/root/showdown/showdown/run_battle.py", line 170, in start_battle battle = await start_random_battle(ps_websocket_client, pokemon_battle_type) File "/root/showdown/showdown/run_battle.py", line 119, in start_random_battle battle, opponent_id, user_json = await initialize_battle_with_tag(ps_websocket_client) File "/root/showdown/showdown/run_battle.py", line 79, in initialize_battle_with_tag battle_tag, opponent_name = await get_battle_tag_and_opponent(ps_websocket_client) File "/root/showdown/showdown/run_battle.py", line 66, in get_battle_tag_and_opponent msg = await ps_websocket_client.receive_message() File "/root/showdown/showdown/websocket_client.py", line 45, in receive_message message = await self.websocket.recv() File "/usr/local/lib/python3.10/dist-packages/websockets/legacy/protocol.py", line 553, in recv await self.ensure_open() File "/usr/local/lib/python3.10/dist-packages/websockets/legacy/protocol.py", line 930, in ensure_open raise self.connection_closed_exc() websockets.exceptions.ConnectionClosedOK: received 1000 (OK) Normal closure; then sent 1000 (OK) Normal closure

pmariglia commented 3 months ago

How often do you see this?

1000 OK normal closure typically implies that P.S. closed the connection, and this is an expected closure.

If you saw this only once I wouldn't worry. If you see it very often could you provide your env configuration (omit credentials) and the logs leading up to this error?

xumical commented 3 months ago

How often do you see this?

1000 OK normal closure typically implies that P.S. closed the connection, and this is an expected closure.

If you saw this only once I wouldn't worry. If you see it very often could you provide your env configuration (omit credentials) and the logs leading up to this error?

Hello! Sorry for the late reply. This happens everytime I run the run.py file.

Here is my currently env with redacts creds

BATTLE_BOT=safest WEBSOCKET_URI=wss://sim3.psim.us/showdown/websocket PS_USERNAME=REDACTED PS_PASSWORD=REDACTED BOT_MODE=SEARCH_LADDER POKEMON_MODE=gen9randombattle RUN_COUNT=1

USER_TO_CHALLENGE=SomeOtherPerson TEAM_NAME=gen8/ou/clef_sand SAVE_REPLAY=False

This is what I see after I run:

python3 run.py [DEBUG] Logging in... [DEBUG] Received message from websocket: |updateuser| Guest 809845|0|265|{"blockChallenges":false,"blockPMs":false,"ignoreTickets":false,"hideBattlesFromTrainerCard":false,"blockInvites":false,"doNotDisturb":false,"blockFriendRequests":false,"allowFriendNotifications":false,"displayBattlesToFriends":false,"hideLogins":false,"hiddenNextBattle":false,"inviteOnlyNextBattle":false,"language":null} |formats|,1|S/V Singles|[Gen 9] Random Battle,f|[Gen 9] Unrated Random Battle,b|[Gen 9] Free-For-All Random Battle,7|[Gen 9] Random Battle (Blitz),f|[Gen 9] Multi Random Battle,5|[Gen 9] OU,e|[Gen 9] Ubers,e|[Gen 9] UU,e|[Gen 9] RU,e|[Gen 9] NU,e|[Gen 9] PU,e|[Gen 9] LC,e|[Gen 9] Monotype,e|[Gen 9] CAP,e|[Gen 9] BSS Reg G,5e|[Gen 9] Custom Game,c|,1|S/V Doubles|[Gen 9] Random Doubles Battle,f|[Gen 9] Doubles OU,e|[Gen 9] Doubles Ubers,e|[Gen 9] Doubles UU,e|[Gen 9] Doubles LC,c|[Gen 9] VGC 2023 Reg D,5c|[Gen 9] VGC 2024 Reg G,5e|[Gen 9] VGC 2024 Reg G (Bo3),1a|[Gen 9] Doubles Custom Game,c|,1|Unofficial Metagames|[Gen 9] 1v1,e|[Gen 9] 2v2 Doubles,e|[Gen 9] Anything Goes,e|[Gen 9] Ubers UU,e|[Gen 9] ZU,e|[Gen 9] Free-For-All,6|[Gen 9] LC UU,c|[Gen 9] NFE,c|,1|Pet Mods|[Gen 9] Do Not Use,c|[Gen 2] Modern Gen 2,c|[Gen 6] NEXT OU,8|,1|Draft|[Gen 9] Draft,c|[Gen 9] Tera Preview Draft,c|[Gen 9] 6v6 Doubles Draft,c|[Gen 9] 4v4 Doubles Draft,5c|[Gen 9] NatDex Draft,c|[Gen 9] Tera Preview NatDex Draft,c|[Gen 9] NatDex 6v6 Doubles Draft,c|[Gen 9] NatDex LC Draft,c|[Gen 8] Galar Dex Draft,c|[Gen 8] NatDex Draft,c|[Gen 8] NatDex 4v4 Doubles Draft,1c|[Gen 7] Draft,c|[Gen 6] Draft,c|,2|OM of the Month|[Gen 9] Frantic Fusions,e|[Gen 9] Category Swap,e|[Gen 9] Inheritance,e|,2|Other Metagames|[Gen 9] Almost Any Ability,e|[Gen 9] Balanced Hackmons,e|[Gen 9] Godly Gift,e|[Gen 9] Mix and Mega,e|[Gen 9] Partners in Crime,e|[Gen 9] Shared Power,e|[Gen 9] STABmons,e|[Gen 7] Pure Hackmons,e|,2|Challengeable OMs|[Gen 9] 350 Cup,c|[Gen 9] Camomons,c|[Gen 9] Convergence,c|[Gen 9] Cross Evolution,c|[Gen 9] Fervent Impersonation,c|[Gen 9] Foresighters,c|[Gen 9] Fortemons,c|[Gen 9] Full Potential,c|[Gen 9] Pokebilities,c|[Gen 9] Pure Hackmons,c|[Gen 9] Revelationmons,c|[Gen 9] Sharing is Caring,c|[Gen 9] Tera Donation,c|[Gen 9] The Card Game,c|[Gen 9] The Loser's Game,c|[Gen 9] Trademarked,c|[Gen 9] Type Split,c|[Gen 6] Pure Hackmons,c|,2|National Dex|[Gen 9] National Dex,e|[Gen 8] National Dex,e|,2|National Dex Other Tiers|[Gen 9] National Dex Ubers,e|[Gen 9] National Dex UU,e|[Gen 9] National Dex RU,c|[Gen 9] National Dex LC,c|[Gen 9] National Dex Monotype,e|[Gen 9] National Dex Doubles,e|[Gen 9] National Dex Ubers UU,c|[Gen 9] National Dex AG,c|[Gen 9] National Dex BH,e|[Gen 8] National Dex UU,c|[Gen 8] National Dex Monotype,c|,3|Randomized Format Spotlight|[Gen 9] CAP Random Battle,f|,3|Randomized Metas|[Gen 9] Random Roulette,d|[Gen 9] Super Staff Bros Ultimate,f|[Gen 9] Monotype Random Battle,f|[Gen 9] Random Battle Mayhem,f|[Gen 9] BSS Factory,1f|[Gen 9] Baby Random Battle,f|[Gen 9] Computer-Generated Teams,f|[Gen 9] Hackmons Cup,f|[Gen 9] Doubles Hackmons Cup,d|[Gen 9] Broken Cup,d|[Gen 9] Challenge Cup 1v1,f|[Gen 9] Challenge Cup 2v2,f|[Gen 9] Challenge Cup 6v6,d|[Gen 9] Metronome Battle,e|[Gen 8] Random Battle,f|[Gen 8] Random Doubles Battle,f|[Gen 8] Free-For-All Random Battle,7|[Gen 8] Multi Random Battle,5|[Gen 8] Battle Factory,f|[Gen 8] BSS Factory,1d|[Gen 8] Hackmons Cup,f|[Gen 8] Metronome Battle,c|[Gen 8] CAP 1v1,d|[Gen 8 BDSP] Random Battle,d|[Gen 7] Random Battle,f|[Gen 7] Battle Factory,f|[Gen 7] BSS Factory,1d|[Gen 7] Hackmons Cup,d|[Gen 7 Let's Go] Random Battle,d|[Gen 6] Random Battle,f|[Gen 6] Battle Factory,9|[Gen 5] Random Battle,f|[Gen 4] Random Battle,f|[Gen 3] Random Battle,f|[Gen 2] Random Battle,f|[Gen 1] Random Battle,f|[Gen 1] Challenge Cup,9|[Gen 1] Hackmons Cup,9|,4|RoA Spotlight|[Gen 8] UU,e|[Gen 5] BW1 OU,e|[Gen 3] ZU,e|[Gen 1] ZU,e|,4|Past Gens OU|[Gen 8] OU,e|[Gen 7] OU,e|[Gen 6] OU,e|[Gen 5] OU,e|[Gen 4] OU,e|[Gen 3] OU,e|[Gen 2] OU,e|[Gen 1] OU,e|,4|Past Gens Doubles OU|[Gen 8] Doubles OU,e|[Gen 7] Doubles OU,e|[Gen 6] Doubles OU,e|[Gen 5] Doubles OU,c|[Gen 4] Doubles OU,c|[Gen 3] Doubles OU,c|,4|Sw/Sh Singles|[Gen 8] Ubers,c|[Gen 8] RU,c|[Gen 8] NU,c|[Gen 8] PU,c|[Gen 8] LC,c|[Gen 8] Monotype,c|[Gen 8] 1v1,c|[Gen 8] Anything Goes,c|[Gen 8] ZU,c|[Gen 8] CAP,c|[Gen 8] Battle Stadium Singles,5c|[Gen 8 BDSP] OU,c|[Gen 8 BDSP] Ubers,c|[Gen 8] Custom Game,c|,4|Sw/Sh Doubles|[Gen 8] Doubles Ubers,c|[Gen 8] Doubles UU,c|[Gen 8] VGC 2022,5c|[Gen 8] VGC 2021,5c|[Gen 8] VGC 2020,5c|[Gen 8 BDSP] Doubles OU,c|[Gen 8 BDSP] Battle Festival Doubles,1c|[Gen 8] Doubles Custom Game,c|,4|US/UM Singles|[Gen 7] Ubers,c|[Gen 7] UU,c|[Gen 7] RU,c|[Gen 7] NU,c|[Gen 7] PU,c|[Gen 7] LC,c|[Gen 7] Monotype,c|[Gen 7] 1v1,c|[Gen 7] Anything Goes,c|[Gen 7] ZU,c|[Gen 7] CAP,c|[Gen 7] Battle Spot Singles,5c|[Gen 7 Let's Go] OU,1c|[Gen 7] Custom Game,c|,4|US/UM Doubles|[Gen 7] Doubles UU,c|[Gen 7] VGC 2019,5c|[Gen 7] VGC 2018,5c|[Gen 7] VGC 2017,5c|[Gen 7] Battle Spot Doubles,5c|[Gen 7 Let's Go] Doubles OU,c|[Gen 7] Doubles Custom Game,c|,4|OR/AS Singles|[Gen 6] Ubers,c|[Gen 6] UU,c|[Gen 6] RU,c|[Gen 6] NU,c|[Gen 6] PU,c|[Gen 6] LC,c|[Gen 6] Monotype,c|[Gen 6] 1v1,c|[Gen 6] Anything Goes,c|[Gen 6] ZU,c|[Gen 6] CAP,c|[Gen 6] Battle Spot Singles,5c|[Gen 6] Custom Game,c|,4|OR/AS Doubles/Triples|[Gen 6] VGC 2016,5c|[Gen 6] VGC 2015,5c|[Gen 6] VGC 2014,5c|[Gen 6] Battle Spot Doubles,5c|[Gen 6] Doubles Custom Game,c|[Gen 6] Battle Spot Triples,1c|[Gen 6] Triples Custom Game,c|,4|B2/W2 Singles|[Gen 5] Ubers,c|[Gen 5] UU,c|[Gen 5] RU,c|[Gen 5] NU,c|[Gen 5] PU,c|[Gen 5] LC,c|[Gen 5] Monotype,c|[Gen 5] 1v1,c|[Gen 5] ZU,c|[Gen 5] CAP,c|[Gen 5] GBU Singles,5c|[Gen 5] Custom Game,c|,4|B2/W2 Doubles|[Gen 5] VGC 2013,5c|[Gen 5] VGC 2012,5c|[Gen 5] VGC 2011,5c|[Gen 5] Doubles Custom Game,c|[Gen 5] Triples Custom Game,c|,4|DPP Singles|[Gen 4] Ubers,c|[Gen 4] UU,c|[Gen 4] NU,c|[Gen 4] PU,c|[Gen 4] LC,c|[Gen 4] Anything Goes,c|[Gen 4] 1v1,c|[Gen 4] ZU,c|[Gen 4] CAP,c|[Gen 4] Custom Game,c|,4|DPP Doubles|[Gen 4] VGC 2010,1c|[Gen 4] VGC 2009,1c|[Gen 4] Doubles Custom Game,c|,4|Past Generations|[Gen 3] Ubers,c|[Gen 3] UU,c|[Gen 3] RU,c|[Gen 3] NU,c|[Gen 3] PU,c|[Gen 3] LC,c|[Gen 3] 1v1,c|[Gen 3] Custom Game,c|[Gen 3] Doubles Custom Game,c|[Gen 2] Ubers,c|[Gen 2] UU,c|[Gen 2] NU,c|[Gen 2] PU,c|[Gen 2] ZU,c|[Gen 2] 1v1,c|[Gen 2] NC 2000,c|[Gen 2] Stadium OU,c|[Gen 2] Custom Game,c|[Gen 1] Ubers,c|[Gen 1] UU,c|[Gen 1] NU,c|[Gen 1] PU,c|[Gen 1] 1v1,c|[Gen 1] Japanese OU,c|[Gen 1] Stadium OU,c|[Gen 1] Tradebacks OU,c|[Gen 1] NC 1997,c|[Gen 1] Custom Game,c [DEBUG] Received message from websocket: |challstr|4|74ed1af09f2f6f554f23567dada220f2ded7358dd117c6455b84de18c37d648ad902f9f36da03385cfd538b8cd5e04af6f6bf02ce3f8870fe3e1efec8493fc4574015211238cd727bb83318915fb632567f9cb6162afce8bb58c6b6a602e060ecc472c31383dba4c0b683d253c1a2b012339b2a3390ab3c84197d7641d51013f [DEBUG] Successfully logged in [DEBUG] Sending message to websocket: |/trn minaxov,0,74ed1af09f2f6f554f23567dada220f2ded7358dd117c6455b84de18c37d648ad902f9f36da03385cfd538b8cd5e04af6f6bf02ce3f8870fe3e1efec8493fc4574015211238cd727bb83318915fb632567f9cb6162afce8bb58c6b6a602e060ecc472c31383dba4c0b683d253c1a2b012339b2a3390ab3c84197d7641d51013f,minaxov,4,1722128301,sim3.psim.us,c1e182fbbd013ce61722128301,9bf07728b47dc51f,;04cc99867f71294e77432d786a54f27c581fed0b1e328bcaa3c5c108da83b521d1301bf80a9602e74b1195d8415d51186a7fab25409240b2e4fbc732ca181b62e7bd4bad13cbf3321665c3f61135ad7738926ff0e0ba551ec2e742451558729543e6325dd188486d2e4514ea199d74d7d0632bbeb2dcd7623aa3df4753b999cff0242f5a7b3001cc92b76246e4847c9af15e94bf4f30f45162321477028b013403eca29fd3d75477332421cd5cb70942be4a0a806d51edb047e6ea1f676bd22dff3c9b3ba1f12365c29526e01b9771ce04f934b903088581971fe052df8eeeda2cb2a8b88f9324e77f005d128e8e463dff58c137f67605b69aea45244cd059f02a89a40c4fd9926300fcb6c36cd8fad78e981b1d72eb19d39fa1aeacc7124dd01b91ba166b662ab6c4483c6541b023d76a2c4f6b7de3b981884125844e8ea5d74bac8e92ad475c961ee563e0d888cc9e664b863f70c59837630192f29ab857194cc7d36966c49911f883cd89653a4bac85f12945bb980c54f279102ec456bc439ca76115d940960c1ea36f775c471000ea7e543591cb3ba45b76f101628c68f0a19a9439dee05e63b4754d147f911bb222b0c72bc0a2a3de87d5598ae663128daa8302cf55f253cff1b843f26cf99c66a6a1548d9bac27338151114e3f2b32bef113cceaa42ca2464999935d880db6186a5af3f412ef240cf7c8da2b541e4814 [DEBUG] Searching for ranked gen9randombattle match [INFO] Setting team to None because the pokemon mode is gen9randombattle [DEBUG] Sending message to websocket: |/utm None [DEBUG] Sending message to websocket: |/search gen9randombattle [DEBUG] Received message from websocket: |updatesearch|{"searching":[],"games":null} [DEBUG] Received message from websocket: |updateuser| minaxov|1|2|{"blockChallenges":false,"blockPMs":false,"ignoreTickets":false,"hideBattlesFromTrainerCard":false,"blockInvites":false,"doNotDisturb":false,"blockFriendRequests":false,"allowFriendNotifications":false,"displayBattlesToFriends":false,"hideLogins":false,"hiddenNextBattle":false,"inviteOnlyNextBattle":false,"language":null} [DEBUG] Received message from websocket: |updatesearch|{"searching":[],"games":null} [ERROR] Traceback (most recent call last): File "/root/showdown/run.py", line 103, in asyncio.run(showdown()) File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/root/showdown/run.py", line 87, in showdown winner = await pokemon_battle(ps_websocket_client, ShowdownConfig.pokemon_mode) File "/root/showdown/showdown/run_battle.py", line 181, in pokemon_battle battle = await start_battle(ps_websocket_client, pokemon_battle_type) File "/root/showdown/showdown/run_battle.py", line 170, in start_battle battle = await start_random_battle(ps_websocket_client, pokemon_battle_type) File "/root/showdown/showdown/run_battle.py", line 119, in start_random_battle battle, opponent_id, user_json = await initialize_battle_with_tag(ps_websocket_client) File "/root/showdown/showdown/run_battle.py", line 79, in initialize_battle_with_tag battle_tag, opponent_name = await get_battle_tag_and_opponent(ps_websocket_client) File "/root/showdown/showdown/run_battle.py", line 66, in get_battle_tag_and_opponent msg = await ps_websocket_client.receive_message() File "/root/showdown/showdown/websocket_client.py", line 45, in receive_message message = await self.websocket.recv() File "/usr/local/lib/python3.10/dist-packages/websockets/legacy/protocol.py", line 553, in recv await self.ensure_open() File "/usr/local/lib/python3.10/dist-packages/websockets/legacy/protocol.py", line 930, in ensure_open raise self.connection_closed_exc() websockets.exceptions.ConnectionClosedOK: received 1000 (OK) Normal closure; then sent 1000 (OK) Normal closure

Traceback (most recent call last): File "/root/showdown/run.py", line 103, in asyncio.run(showdown()) File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/root/showdown/run.py", line 87, in showdown winner = await pokemon_battle(ps_websocket_client, ShowdownConfig.pokemon_mode) File "/root/showdown/showdown/run_battle.py", line 181, in pokemon_battle battle = await start_battle(ps_websocket_client, pokemon_battle_type) File "/root/showdown/showdown/run_battle.py", line 170, in start_battle battle = await start_random_battle(ps_websocket_client, pokemon_battle_type) File "/root/showdown/showdown/run_battle.py", line 119, in start_random_battle battle, opponent_id, user_json = await initialize_battle_with_tag(ps_websocket_client) File "/root/showdown/showdown/run_battle.py", line 79, in initialize_battle_with_tag battle_tag, opponent_name = await get_battle_tag_and_opponent(ps_websocket_client) File "/root/showdown/showdown/run_battle.py", line 66, in get_battle_tag_and_opponent msg = await ps_websocket_client.receive_message() File "/root/showdown/showdown/websocket_client.py", line 45, in receive_message message = await self.websocket.recv() File "/usr/local/lib/python3.10/dist-packages/websockets/legacy/protocol.py", line 553, in recv await self.ensure_open() File "/usr/local/lib/python3.10/dist-packages/websockets/legacy/protocol.py", line 930, in ensure_open raise self.connection_closed_exc() websockets.exceptions.ConnectionClosedOK: received 1000 (OK) Normal closure; then sent 1000 (OK) Normal closure

xumical commented 3 months ago

I'm also running this through a VPS, not sure if this would cause issues.

pmariglia commented 2 months ago

The VPS smells like the culprit here. I haven't had any issues running so I'm not sure what else to look at.

I'd check if you can connect to the P.S. websocket by other means (browser, directly via the websocket by some other means).