EventSub webhook times out even though my server returns the appropriate response

I have a webhook sub event server set up and it is working. I can use the twitchcli event to verify the subscription and receive the following:
:check_mark: Valid response. Received challenge in body
:check_mark: Valid content-type header. Received type text/plain
:check_mark: Valid status code. Received status 200

However, when I try to sub to an event, it times out every time. Twitch shows the sub as enabled, but I can’t callback to my local code. Here’s a snippet:

await eventSub.listen_stream_online(broadcaster_user_id=channel.user_id, callback=attach_to_stream)

Where attach_to_stream is
async def attach_to_stream(event: StreamOnlineEvent):
dict = event.to_dict()
await chat.join_room(dict[‘event’][“broadcaster_user_name”])
await chat.send_message(text=“Your AI chat assistant, reporting for duty!\r\n”, room=dict[‘event’][“broadcaster_user_name”])

Does anyone have any suggestions as to what’s wrong? Thanks!

local code as in localhost?

Webhooks need to be web accessable.

The CLI is on your machine so the CLI can call you machine.

“real”/production the eventsub server cannot call localhost as localhost is itself.

This sounds like you probably should be using websockets not webhooks.

Especially if you are running on localhost/not deploying to something web accessable

I am running these on 2 Azure Linux VMs. I tried WebSockets, but ran out of socket subs really fast for what I’m trying to do and research indicates for me to get around that, I needed to switch to web hooks. Again, the subscription goes through on twitch’s end. I can ping subscriptions and get a list of enabled subs, it just never calls back to my original code to set up my callback.

Does it remain enabled?

As in it goes to pending and then transitions to enabled?

As this sounds like firewall schnangians.

I realized there could still be ambiguity so I made this helpful diagram. :smiley:

I thought it was a firewall issue, so I temporarily turned it off and it still times out. :frowning:

I really appreciate your attention to this! Thank you for looking into it with me!

Could be other firewally type things at the azure level, or the box level.

You’ll also need/want to check your SSL configuration, you can use SSL Server Test (Powered by Qualys SSL Labs)

So you need a “real” SSL cert and it needs to be correclty configured.

TwitchCLI will trust whatever your computer trusts.

Thank you, again, for the quick reply. I tested both of my servers and both return an A result. Is there another port I should allow on the Azure side? I have included inbound and outbound rules for ports 80 and 443.

80 is for non ssl traffic
443 is for ssl’ed traffic

callback URI should be just https://mydomain/anypath

No :443 or anything (and path optional depends where your handler is) but a :portnumber in the URI is likely not to work.

So to confirm:

  • makign a sub
  • seeing it hit your URI to do the verification
  • the sub becomes enabled (from pending callback check)
  • and just not getting a stream up event?

So you are live long enough on the channel in question? And the channel isn’t in broadcast test mode in their streaming software?

And your logs/access/code logs are not seeing any event POST calls? (As could be hitting HTTP and not being routed to your handler)

This is a chat bot I’m making. It’s not gonna stream, but it is logging in and authorizing correctly to sub to these events. If I kick off the bot after getting the subs on twitch, it will start chatting with live followers, but if someone goes live, the sub callback never reaches the bot end. I have tried setting eventsub.wait_for_subscription_confirm to false, but that just gets around the timeout issue, it doesn’t actually bind the eventsub listener.

Oh, and let me dig through logs. You may be onto something with that port 80 and I’m only redirecting 443.

Sounds like a library issue

that just gets around the timeout issue

Not sure what is timing out.

if it doesn’t bind then you code won’t response to stream ups

I meant the broadcasters that it is waiting for a stream up on.

My mistake! I have code to check if they’re live and handle correctly connecting and messaging if they are. The main setup is to go through the bot’s followers and set up the subs for each follower (that’s how they invite the bot into their stream - follow it) and set up a sub (if it doesn’t already exist) to check when that follower goes live so it can connect to chat and when they go offline so it can disconnect from chat. I see what you mean by it may be a library issue. If the port checks aren’t the issue, I can try the old school request/response method and see I can get something working. :slight_smile:

This is the wrong approach.

You’ll hit chat join limits.

You should be doing oAuth instead.

Okay! I’ll look into this approach! Thanks!

Sorry it’s been a minute! I wanted to give an update. I was able to get the bot up and running on Friday using the advice you gave me. It’s working just like it’s supposed to, now. Thank you so much for you assistance! (For your heads up, I switched to a full webhook handler, so it’s all handled on the same server within the webhook handlers :slight_smile: )