Skip to content
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

Error occurred when playing against a computer #256

Closed
Arturas1989 opened this issue Feb 6, 2024 · 15 comments
Closed

Error occurred when playing against a computer #256

Arturas1989 opened this issue Feb 6, 2024 · 15 comments
Labels
bug Something isn't working

Comments

@Arturas1989
Copy link

Arturas1989 commented Feb 6, 2024

An error occurred when I played against a computer.

image

@Arturas1989 Arturas1989 changed the title Error when playing against a computer Error occurred when playing against a computer Feb 6, 2024
@programarivm
Copy link
Member

Thank you @Arturas1989 for opening this issue!

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

See chesslablab/spablab#600

@programarivm programarivm added the bug Something isn't working label Feb 6, 2024
@Arturas1989
Copy link
Author

Arturas1989 commented Feb 6, 2024

@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.

@d47081
Copy link

d47081 commented Feb 6, 2024

Same here

image

@programarivm
Copy link
Member

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:https://0.0.0.0:8443    1             [OK]            
--------------------------------------------------------------------------------------------------
Press Ctrl+C to stop. Start success.
Warning: User unknown not exists

@d47081
Copy link

d47081 commented Feb 20, 2024

https://ui.chesslablab.org/

image

@programarivm programarivm reopened this Feb 21, 2024
@programarivm programarivm transferred this issue from chesslablab/spablab Feb 21, 2024
@programarivm
Copy link
Member

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

@programarivm
Copy link
Member

programarivm commented Feb 21, 2024

🙏 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?

@d47081
Copy link

d47081 commented Feb 21, 2024

Thanks, check my trace please

image

@d47081
Copy link

d47081 commented Feb 21, 2024

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

@programarivm
Copy link
Member

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.

@programarivm
Copy link
Member

The stack trace is being logged now. See #262

@programarivm
Copy link
Member

The WebSocket messages need to be logged. See #264

@programarivm
Copy link
Member

programarivm commented Feb 25, 2024

Opened discussion:

@programarivm
Copy link
Member

Fixed bug chesslablab/php-chess#482

@d47081
Copy link

d47081 commented Mar 24, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants