chesslablab/chess-server

Error occurred when playing against a computer

Arturas1989 opened this issue ยท 15 comments

An error occurred when I played against a computer.

image

Thank you @Arturas1989 for opening this issue!

Does the error occur frequently? And can it be replicated?

See chesslablab/spablab#600

@programarivm I only played it once and it occurred. The only replication of the error I know is manual :) Inspect the code responsible for playing with a computer and try to catch errors.

Same here

image

Most probably this is because Workerman WebSockets were recently added and the recent changes were not pulled.

git pull origin master
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 11 (delta 7), reused 11 (delta 7), pack-reused 0
Unpacking objects: 100% (11/11), 777 bytes | 129.00 KiB/s, done.
From https://github.com/chesslablab/chess-server
 * branch            master     -> FETCH_HEAD
   cb099c6..d9e9309  master     -> origin/master
Updating cb099c6..d9e9309
Fast-forward
 cli/ratchet/wss.php                   |  3 +--
 cli/workerman/wss.php                 |  3 +--
 src/Socket/RatchetClientStorage.php   | 11 +----------
 src/Socket/WorkermanClientStorage.php | 11 +----------
 4 files changed, 4 insertions(+), 24 deletions(-)
docker logs chess_server_php_fpm 
Welcome to PHP Chess Server
Commands available:
/accept {"jwt":"<string>"} Accepts an invitation to play online with an opponent.
/draw {"action":["accept","decline","propose"]} Allows to offer a draw.
/heuristics {"fen":"<string>","variant":"<string>"} Returns the heuristics of a chess position.
/leave {"action":["accept"]} Allows to leave a game.
/legal {"position":"<string>"} Returns the legal FEN positions of a piece.
/online_games Returns the online games waiting to be accepted.
/play_lan {"color":"<string>","lan":"<string>"} Plays a chess move in long algebraic notation.
/randomizer {"turn":"<string>","items":"<string>"} Starts a random position.
/rematch {"action":["accept","decline","propose"]} Allows to offer a rematch.
/resign {"action":["accept"]} Allows to resign a game.
/restart {"hash":"<string>"} Restarts a game.
/start {"variant":["960","capablanca","capablanca-fischer","classical"],"mode":["fen","san","play","stockfish"],"settings":{"color":["w","b"],"fen":"<string>","movetext":"<string>","settings":"<string>","startPos":"<string>"}} Starts a new game.
/stockfish {"options":{"Skill Level":"int"},"params":{"depth":"int"}} Returns Stockfish's response to the current position.
/stockfish_eval {"fen":"<string>","variant":"<string>"} Returns Stockfish's evaluation for the given position.
/takeback {"action":["accept","decline","propose"]} Allows to takeback a move.
/tutor_fen {"fen":"<string>","variant":"<string>"} Explains a FEN position in terms of chess concepts.
/undo Undoes the last move.

Listening to commands...
Workerman[cli/workerman/wss.php] start in DEBUG mode
------------------------------------------- WORKERMAN --------------------------------------------
Workerman version:4.1.14          PHP version:8.3.2           Event-Loop:\Workerman\Events\Select
-------------------------------------------- WORKERS ---------------------------------------------
proto   user            worker          listen                      processes    status           
ssl     unknown         none            websocket://0.0.0.0:8443    1             [OK]            
--------------------------------------------------------------------------------------------------
Press Ctrl+C to stop. Start success.
Warning: User unknown not exists

Thank you @d47081 for reporting this issue, it seems as if the errors are not being logged. See #257

๐Ÿ™ Thank you @Arturas1989, @CodeMaster7000 @d47081, @Mayank2001kh for the help on this issue, it is very much appreciated! Now all objects implementing the Throwable interface are being catched and logged in the storage/pchess.log file. Could the "Whoops!" message be reproduced now to see what the log file reports?

Thanks, check my trace please

image

I think this issue could be related with same problem as fixed here #233 (chesslablab/php-chess#442)

The stack trace is not being logged.

cat pchess.log | grep error
[2024-02-21T19:05:46.230919+00:00] log.ERROR: Occurred an error {"message":"","file":"/usr/share/chess-server/vendor/chesslablab/php-chess/src/Variant/Classical/PGN/Move.php","line":301} []
[2024-02-21T19:05:46.231009+00:00] log.INFO: Sent message {"id":21,"cmd":["error"]} []

Also at the moment only the command names are logged so it remains unknown which move exactly threw the exception.

...
[2024-02-21T19:04:36.453698+00:00] log.INFO: New connection {"id":21,"n":1} []
[2024-02-21T19:04:36.521191+00:00] log.INFO: Sent message {"id":21,"cmd":["/start"]} []
[2024-02-21T19:04:45.723480+00:00] log.INFO: Sent message {"id":21,"cmd":["/start"]} []
[2024-02-21T19:04:46.666906+00:00] log.INFO: Sent message {"id":21,"cmd":["/legal"]} []
[2024-02-21T19:04:47.255247+00:00] log.INFO: Sent message {"id":21,"cmd":["/play_lan"]} []
[2024-02-21T19:04:47.857739+00:00] log.INFO: Sent message {"id":21,"cmd":["/stockfish"]} []
[2024-02-21T19:04:48.264194+00:00] log.INFO: Sent message {"id":21,"cmd":["/legal"]} []
[2024-02-21T19:04:48.828461+00:00] log.INFO: Sent message {"id":21,"cmd":["/play_lan"]} []
[2024-02-21T19:04:49.410408+00:00] log.INFO: Sent message {"id":21,"cmd":["/stockfish"]} []
[2024-02-21T19:04:50.837939+00:00] log.INFO: Sent message {"id":21,"cmd":["/legal"]} []
[2024-02-21T19:04:51.479351+00:00] log.INFO: Sent message {"id":21,"cmd":["/play_lan"]} []
[2024-02-21T19:04:52.102421+00:00] log.INFO: Sent message {"id":21,"cmd":["/stockfish"]} []
[2024-02-21T19:04:55.234495+00:00] log.INFO: Sent message {"id":21,"cmd":["/legal"]} []
[2024-02-21T19:04:58.990147+00:00] log.INFO: Sent message {"id":21,"cmd":["/play_lan"]} []
[2024-02-21T19:04:59.615559+00:00] log.INFO: Sent message {"id":21,"cmd":["/stockfish"]} []
[2024-02-21T19:05:05.031748+00:00] log.INFO: Sent message {"id":21,"cmd":["/legal"]} []
[2024-02-21T19:05:06.015237+00:00] log.INFO: Sent message {"id":21,"cmd":["/play_lan"]} []
[2024-02-21T19:05:06.674021+00:00] log.INFO: Sent message {"id":21,"cmd":["/stockfish"]} []
[2024-02-21T19:05:22.376442+00:00] log.INFO: Sent message {"id":21,"cmd":["/legal"]} []
[2024-02-21T19:05:27.390752+00:00] log.INFO: Sent message {"id":21,"cmd":["/legal"]} []
[2024-02-21T19:05:27.791096+00:00] log.INFO: Sent message {"id":21,"cmd":["/legal"]} []
[2024-02-21T19:05:27.902157+00:00] log.INFO: Sent message {"id":21,"cmd":["/legal"]} []
[2024-02-21T19:05:30.823827+00:00] log.INFO: Sent message {"id":21,"cmd":["/legal"]} []
[2024-02-21T19:05:30.959547+00:00] log.INFO: Sent message {"id":21,"cmd":["/legal"]} []
[2024-02-21T19:05:34.927681+00:00] log.INFO: Sent message {"id":21,"cmd":["/legal"]} []
[2024-02-21T19:05:35.055583+00:00] log.INFO: Sent message {"id":21,"cmd":["/legal"]} []
[2024-02-21T19:05:36.406424+00:00] log.INFO: Sent message {"id":21,"cmd":["/legal"]} []
[2024-02-21T19:05:37.271844+00:00] log.INFO: Sent message {"id":21,"cmd":["/play_lan"]} []
[2024-02-21T19:05:38.093021+00:00] log.INFO: Sent message {"id":21,"cmd":["/stockfish"]} []
[2024-02-21T19:05:40.840354+00:00] log.INFO: Sent message {"id":21,"cmd":["/legal"]} []
[2024-02-21T19:05:41.771949+00:00] log.INFO: Sent message {"id":21,"cmd":["/play_lan"]} []
[2024-02-21T19:05:43.005086+00:00] log.INFO: Sent message {"id":21,"cmd":["/stockfish"]} []
[2024-02-21T19:05:44.731110+00:00] log.INFO: Sent message {"id":21,"cmd":["/legal"]} []
[2024-02-21T19:05:45.395565+00:00] log.INFO: Sent message {"id":21,"cmd":["/play_lan"]} []
[2024-02-21T19:05:46.230919+00:00] log.ERROR: Occurred an error {"message":"","file":"/usr/share/chess-server/vendor/chesslablab/php-chess/src/Variant/Classical/PGN/Move.php","line":301} []
[2024-02-21T19:05:46.231009+00:00] log.INFO: Sent message {"id":21,"cmd":["error"]} []
...

It seems as if src/Variant/Classical/PGN/Move.php needs some fixing.

The stack trace is being logged now. See #262

The WebSocket messages need to be logged. See #264

Fixed bug chesslablab/php-chess#482

you know, I just found the reason of websocket connection error just in broken Ethernet wire :D

pff, it was a long trip but finally we have fixed lot of bugs!