Team-TAU / tau

TAU- Twitch API Unifier, a containerized relay/proxy to unify the WebHook- and WebSocket-based real-time Twitch APIs under a single (local) WebSocket connection.
MIT License
154 stars 39 forks source link

Getting status code 500 error #44

Closed alanwsmith closed 3 years ago

alanwsmith commented 3 years ago

I walked through the install documentation for TAU. I'm able to get the web page to show up and to authenticate with Twitch, but the dashboard only shows spinning icons.

When I look in the console, I see a bunch of these errors:

WebSocket connection to 'ws://localhost:8000/ws/tau-status/' failed: Unexpected response code: 500

The terminal logs when I start up are:

    ❯ docker-compose up
    Creating network "tau_default" with the default driver
    Creating tau-redis ... done
    Creating tau-db    ... done
    Creating tau-app   ... done
    Attaching to tau-redis, tau-db, tau-app
    tau-db   |
    tau-db   | PostgreSQL Database directory appears to contain a database; Skipping initialization
    tau-db   |
    tau-db   | 2021-05-21 02:20:47.901 UTC [1] LOG:  starting PostgreSQL 13.3 (Debian 13.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
    tau-db   | 2021-05-21 02:20:47.901 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
    tau-db   | 2021-05-21 02:20:47.901 UTC [1] LOG:  listening on IPv6 address "::", port 5432
    tau-db   | 2021-05-21 02:20:47.904 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
    tau-db   | 2021-05-21 02:20:47.914 UTC [26] LOG:  database system was shut down at 2021-05-21 02:17:24 UTC
    tau-db   | 2021-05-21 02:20:47.924 UTC [1] LOG:  database system is ready to accept connections
    tau-redis | 1:C 21 May 2021 02:20:47.662 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
    tau-redis | 1:C 21 May 2021 02:20:47.662 # Redis version=6.2.3, bits=64, commit=00000000, modified=0, pid=1, just started
    tau-redis | 1:C 21 May 2021 02:20:47.662 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
    tau-redis | 1:M 21 May 2021 02:20:47.665 * monotonic clock: POSIX clock_gettime
    tau-redis | 1:M 21 May 2021 02:20:47.669 * Running mode=standalone, port=6379.
    tau-redis | 1:M 21 May 2021 02:20:47.669 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
    tau-redis | 1:M 21 May 2021 02:20:47.669 # Server initialized
    tau-redis | 1:M 21 May 2021 02:20:47.669 * Ready to accept connections
    tau-app  | Operations to perform:
    tau-app  |   Apply all migrations: admin, auth, authtoken, contenttypes, database, sessions, streamers, twitchevents, users
    tau-app  | Running migrations:
    tau-app  |   No migrations to apply.
    tau-app  |
    tau-app  | 184 static files copied to '/code/static'.
    tau-app  | 2021-05-21 02:21:01,596 INFO Set uid to user 0 succeeded
    tau-app  | 2021-05-21 02:21:01,604 INFO supervisord started with pid 1
    tau-app  | 2021-05-21 02:21:02,614 INFO spawned: 'wsworker' with pid 19
    tau-app  | 2021-05-21 02:21:02,617 INFO spawned: 'server' with pid 20
    tau-app  | 2021-05-21 02:21:03,620 INFO success: wsworker entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
    tau-app  | 2021-05-21 02:21:03,620 INFO success: server entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
    tau-app  | 2021-05-21 02:21:10,762 INFO exited: wsworker (exit status 0; expected)

This is my config file:

# --- EXTERNAL SERVICES ---
POSTGRES_PW=asdfasdf
REDIS=internal
REDIS_SERVER=localhost 

# --- DJANGO SETTINGS ---
DJANGO_DB_TYPE=postgres
DJANGO_DB=tau_db
DJANGO_DB_USER=tau_db
DJANGO_DB_PW=werwerwerwe
DJANGO_DB_URL=tau-db
DJANGO_SECRET_KEY=asdfererererre
DJANGO_CONFIGURATION=Local

# --- SERVER SETTINGS ---
PORT=8000
INT_SERVER_ADDR=0.0.0.0
PROTOCOL=http:
PUBLIC_URL=localhost

# --- TWITCH API DATA ---
TWITCH_APP_ID=BLAHBLAHBLAH
TWITCH_CLIENT_SECRET=BLAHBLAHBLAH
TWITCH_WEBHOOK_SECRET=BLAHBLAHBLAH

# --- NGROK SETTINGS ---
USE_NGROK=True
USE_NGROK_TOKEN=True
NGROK_TOKEN=BLAHBLAHBLAH

I also tried:

REDIS=external

but that didn't fix it

Happy to help troubleshoot.

FiniteSingularity commented 3 years ago

Hi @alanwsmith,

It looks like the twitch websocket/webhook worker code is failing. This is usually due to a misconfiguration, and we're currently working on both simplifying the setup process, improving the setup documentation (apologies, it has some pretty big issues at the moment) and giving better logs to troubleshoot.

Looking at your .env file:

  1. REDIS=internal is the correct way to run it.
  2. Make sure you have the TWITCH_APP_ID and TWITCH_CLIENT_SECRET set properly. Mixing up the two can cause issues.
  3. The TWITCH_WEBHOOK_SECRET must be more than 10 characters, and less than 100.

Number 3. seems to be the one that is most commonly getting people on startup. Please let me know if that fixes things. If not, we'll try some other troubleshooting steps (and in a day or two, I should be merging a branch that will give much better logs for troubleshooting).

alanwsmith commented 3 years ago

Hey @FiniteSingularity ,

I verified the three steps you mentioned and sadly, still no go.

I'll watch for you to publish the branch with more logs. I'm also happy to jump on a screen share at any point if you want to take a more direct look. (I'm TheIdOfAlan on twitch, btw :-)

I've also taken some notes to help with documentation. Once I get up and running, I'll finalize those and then make a PR.

Cheers, and happy weekend,

-a

wwsean08 commented 3 years ago

If you can exec into the tau app container you could cat the logs located under /tmp to hopefully get some better log output in the meantime. What I've done to test and verify it's possible and to find logs as a test:

# docker exec -it tau-app sh
# cd /tmp
# ls
server-stderr---supervisor-AjfaLC.log  supervisord-tmp  supervsiord-tmp  wsworker-stderr---supervisor-tms1qk.log
server-stdout---supervisor-1Ip2gu.log  supervisord.log  tmp6jhzu0ft  wsworker-stdout---supervisor-zWxPFB.log
# cat server-stderr---supervisor-AjfaLC.log
2021-05-22 03:58:49,084 INFO     Starting server at tcp:port=8000:interface=0.0.0.0
2021-05-22 03:58:49,085 INFO     HTTP/2 support not enabled (install the http2 and tls Twisted extras)
2021-05-22 03:58:49,086 INFO     Configuring endpoint tcp:port=8000:interface=0.0.0.0
2021-05-22 03:58:49,088 INFO     Listening on TCP address 0.0.0.0:8000
FiniteSingularity commented 3 years ago

I suspect your issue may have had to do with ngrok connection limits. A couple of merges back, I added some code to decouple the worker process from the database- sending all database inserts to the server process to handle. Unfortunately, I was sending this traffic through ngrok connections, and was hitting connection limits. The last merged PR ( #39 ) fixed this.

FiniteSingularity commented 3 years ago

Saw that everything is now up and running on your stream. I hope you enjoy using TAU!