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
149 stars 38 forks source link

[BUG] Webhook challenge not answered, resulting in web hook subscription always failing #93

Closed techygrrrl closed 2 years ago

techygrrrl commented 2 years ago

Describe the bug

Subscribing to web hook events in the dashboard results in web hook statuses changing from pending to failed. Having implemented Twitch web hooks from scratch, I know that the application needs to respond to a challenge webhook event, so it appears that the Tau application is not responding to the webhook challenges.

I am able to connect via websockets with wscat, post my token, and receive test events, but because the webhooks never fully register, I cannot get real events.

To Reproduce Steps to reproduce the behavior:

  1. Go to /dashboard/webhook-monitor
  2. Click All or Broken
  3. See that the webhook status changes to _pending
  4. See that after some time the status changes to _failed

I have also tried updating the subscription to re-authorize but having inadequate authorization would've failed the initial webhook request, so I don't think this is the issue, and some events like channel.follow require no additional permissions.

Expected behavior I would expect the webhook status to change to enabled.

Screenshots

image image

Deployment:

Additional context

Am I missing something for webhooks to work properly? The console appears to be successful at creating subscriptions but these ultimately error out, likely because Tau doesn't respond to the challenge.

I have tried docker down then docker up again to shut down and restart all the services—no success. All services (tau_db_1, tau_redis_1, tau_app_1) are running.

This appears to be a bug in the software or perhaps your documentation can be improved.

Any help would be appreciated. Thank you!

FiniteSingularity commented 2 years ago

I'm sorry you're having some issues getting TAU to work properly. I think I know what is happening, and you are correct- it is a bit of documentation that needs to be updated.

Unfortunately, a little while back Ngrok stopped allowing anonymous tunnels for HTTP requests- they still allow you to set them up, but then they fail silently, and wont pass the data back through the server (thus why the callback validation is not happening). If you were not providing an Ngrok token in your .env file, you will need to do so. Fortunately, this can all be done with a free Ngrok account- set up an account ( https://dashboard.ngrok.com/signup ) and generate yourself a free tier token. Provide this token by adding the NGROK_TOKEN=<your token> line to your .env file. Then docker compose down; docker compose build; docker compose up which should rebuild the TAU container with the proper NGROK_TOKEN environment variable set up.

I am looking to move TAU away from using ngrok for tunnels, but in the meantime this is what you'll need to do. Apologies for not having this issue documented- I'll be pushing an update to the docs shortly that indicate an ngrok token is required.

As an alternative, you may want to consider running TAU using Railway. A typical instance of TAU falls in their free tier, and since it is a cloud service, it gives you a 24/7 running TAU instance without the need for tunnels. If this is something you're interested in, there are some docs on getting it set up here: https://github.com/Team-TAU/tau/blob/main/docs/deployment/railway.md .

Please let me know if this fixes your issue! If not, we'll have to dig a bit deeper.

techygrrrl commented 2 years ago

@FiniteSingularity thanks so much for your response! Yes, it appears that the ngrok token is the issue. When I signed up and set an auth token, the web hooks got enabled, so that was definitely it!

I noticed there is a file local.md in the docs directory that I stumbled upon when googling. It would be really great to link to this one and railway.md in the main README. I think this would've saved me (and possibly other devs) some time troubleshooting.

I took your advice and set up TAU on Railway. What an amazing service, I didn't know it existed! That's so great of them to offer such a generous free plan. I decided to go that route instead and I'm fully set up with working web hooks sending real events.

I noticed the project also has a Github Action workflow to generate docs. I downloaded these docs and peeked around and they look pretty good. They don't appear to be complete (missing Railway deployment info) but it looks like a great resource. Is there a hosted version somewhere? I haven't seen any links to these docs. It would be really great to see more formal, full-fledged docs.

I've also joined your Discord channel. If you had any questions, you're welcome to DM me on Discord.

I'll close this ticket as my issue is considered resolved, but I think the project would benefit greatly from improved/more discoverable documentation.

Thank you for your time!

FiniteSingularity commented 2 years ago

Glad you got it up and running. Yes, documentation is definitely one of those places that we're trying to improve! I'll definitely take your experience into account as I am clarifying/rewriting sections of the docs. Cheers!