tpavlek / Jeopardy

A PHP/Javascript implementation of the Jeopardy! game
41 stars 15 forks source link

server.php doesn't seem to do anything #21

Closed hav0ck closed 1 year ago

hav0ck commented 4 years ago

I just found this and I was hoping I might be able to use it to run a small Jeopardy Tournament for my Scout Troop.

I got everything install and when I go to the URL I am presented with a simple menu to pick Player 1, 2, or 3. When I select a player (or go to /admin) I see the game board with "Clue" written in the squares. The category squares are empty and clicking on a 'Clue" square does nothing.

I checked my apache (2.4 on ubuntu 18.04) log I see this error:

{main}\n thrown in /home/user/Jeopardy/vendor/league/route/src/Dispatcher.php on line 122, referer: http://jeopardy.url.tld/play/Player3 [Tue Jun 09 10:24:48.278090 2020] [php7:error] [pid 9336] [client ip.add.ress:54224] PHP Fatal error: Uncaught League\Route\Http\Exception\NotFoundException: Not Found in /home/user/Jeopardy/vendor/league/route/src/Dispatcher.php:122\nStack trace:\n#0 /home/user/Jeopardy/vendor/league/route/src/Dispatcher.php(61): League\Route\Dispatcher->handleNotFound()\n#1 /home/user/Jeopardy/client/index.php(83): League\Route\Dispatcher->dispatch('GET', '/favicon.ico')\n#2 {main}\n thrown in /home/user/Jeopardy/vendor/league/route/src/Dispatcher.php on line 122, referer: http://jeopardy.url.tld/admin

I've made sure that the Jeopardy directory has the same ownership as a directory in /var/www

PHP ver installed is: PHP 7.2.24-0ubuntu0.18.04.6 (cli) (built: May 26 2020 13:09:11)

The strange thing is, I see the same thing when I access the site with server.php running or not.

Perhaps my websockets proxy isn't setup right?

My jeopardy.conf file:

<VirtualHost *:80> DocumentRoot /home/user/Jeopardy/client/ ServerName jeopardy.url.tld

<Directory /home/user/Jeopardy/client/> Options +FollowSymlinks AllowOverride All Require all granted

<FilesMatch .php$> SetHandler application/x-httpd-php

RewriteEngine on ProxyPass /ws ws://127.0.0.1:9001/ws/ ProxyPassReverse /ws ws://127.0.0.1:9001/ws/ ProxyRequests off

tpavlek commented 4 years ago

Hey @hav0ck - sorry I don't have too much time to look into this :(.

I can confirm that the board without categories and just displaying "Clue" is what it looks like when the app doesn't have a valid websocket connection. I think the problem is just the ws://127.0.0.1:9001/ws/ in your apache configuration. The server just outputs the websocket on raw port 9001. Here is a configuration for ProxyPass that has worked for me in the past

ProxyPass /ws ws://localhost:9001/
        ProxyPreserveHost On
        ProxyVia full

  <proxy>
    Order deny,allow
    Allow from all
  </proxy>

Hope that helps.

Re the stack trace:

It looks like that stack trace is complaining about not being able to find a favicon.ico file. I'm not sure if that's causing a fatal error, I don't think the project loads one normally so perhaps your browser is automatically trying to load one?

In any case you can try adding a favicon.ico - just google for whatever one you feel like and add that the the client/ directory.

hav0ck commented 4 years ago

Hey @tpavlek thanks for the help.

There is definitely something up with Websockets. Your example isn't working either. I checked and I have the required mod activated in apache. I also checked my router to make sure I was forwarding port 9001 to the correct internal IP as well.

When I do a

sudo netstat -ntlp | grep LISTEN

I can see that it is there is something listening on 9001. tcp 0 0 0.0.0.0:9001 0.0.0.0:* LISTEN 9166/php

As well as Apache: tcp6 0 0 :::8001 ::: LISTEN 7293/apache2 tcp6 0 0 :::80 ::: LISTEN 7293/apache2

Unfortunately there is no change in the results.