I do a Webhooks subscription to follows and streams:
POST to https://api.twitch.tv/helix/webhooks/hub with data: hub.callback=http://{myIP}:4747/twitch&hub.mode=subscribe&hub.topic=https://api.twitch.tv/helix/users/follows?to_id=229132352&hub.lease_seconds=1200
Headers: Authorization: Bearer {token}
POST to https://api.twitch.tv/helix/webhooks/hub with data: hub.callback=http://{myIP}:4747/twitch&hub.mode=subscribe&hub.topic=https://api.twitch.tv/helix/streams?user_id=229132352&hub.lease_seconds=1200
Headers: Authorization: Bearer {token}
I get a response of 202 Accepted. A request comes to my server in which I respond with code 200 and the content contains hub.challenge.
In response, I get {"total":2,"data":[{"topic":"https://api.twitch.tv/helix/streams?user_id=229132352","callback":"http://{myIP}:4747/twitch","expires_at":"2019-09-16T11:30:37Z"},{"topic":"https://api.twitch.tv/helix/users/follows?to_id=229132352","callback":"http://{myIP}:4747/twitch","expires_at":"2019-09-16T11:40:35Z"}],"pagination":{}}
As I understand it, everything is in order and I should get topics when the stream is turned on or follows the channel. I start the stream and follow in the channel, wait 10+ minutes, but the topics never come.
You set the lease_seconds to 1200 that is only 20 minutes.
I’d suggest that your hook expired before it was time to send data.
But you should also check your server logs for incoming POST’s and ensure you are handling POST’s
Clearly the GET’s are working as your successfully created the subscriptions.
Additionally https://api.twitch.tv/helix/users/follows?to_id=229132352 should be https://api.twitch.tv/helix/users/follows?to_id=229132352&first=1 the former does work as it was the “original” topic but the correct topic requires first=1 for follows. Your streams topic is correct
The non first=1 topic will be disabled at some point
The correct topic is https://api.twitch.tv/helix/users/follows?to_id=229132352&first=1
The data in the payloads is different for the old topic compared to the new/correct topic.
As far as I can see there is nothing wrong as my code that consumes the same topics (for different streamers naturally) is working correctly.
Check the logs anyway to see if a POST hit but didn’t hit your code for whatever reason.
Set it longer as you can always unsubscribe/terminate a hook subscription instead, rather than setting it to a shorter time and risking the hook expires instead.
Also, I think all hooks need to be over SSL, that might be a factor
Both your hook callbacks are non ssl in your response. So mixing SSL’s here?
Sorry, this is a problem in my server.
It’s just that the server was written completely by me and it so happened that it broke and closed the request when I tried to write the logs of the response from Webhooks subscription. It turns out that he just killed the thread with the connection and because of this I could not see the result!