Multiple subscription not returning

I have an array of channels (15 in total) that im mapping through and subscribing to, i when i check my logs, it is successfully completing the subscribe and point and the callback is returned successfully. at this point if I go live, i get a notification, everything seems like its working. but when other people go live, I get not response back from twitch.

any ideas?

let users = [{
  twitchUserId: 1111111,
  twitchUser: 'twitchname'
}, {
  twitchUserId: 2222222,
  twitchUser: 'anothertwitchname'
}]; => {
    method: 'post',
    url: '',
    headers: {'client-ID': {myclientid}'},
    data: {
      "hub.callback": `${baseCallback}/api/twitch/callback`,
      "hub.mode": 'subscribe',
      "hub.topic": `${user.twitchUserId}`,
      "hub.lease_seconds": 10000,
      "hub.secret": '{mysecret}'
  .then(function(response) {
    console.log('subscribed to twitch hub: channel', user.twitchUserId, user.twitchUserId, response.status);
  .catch(function(error) {
    console.log('error', error);

app.get('/api/twitch/callback', (req, res) => {
  const challenge = req.query['hub.challenge'];
});'/api/twitch/callback', (req, res) => { .... this function works when i go live...

First, you can get rid of 'Accept': 'application/vnd.twitchtv.v5+json' as v5 is part of the old API and not part of the new API (Helix) so doesn’t do anything.

Secondly, I don’t know the the structure of your users array and user objects, but you’re mapping over a users array, and using the variable affiliate for each user in that array, but you’re never actually using that anywhere. The places where you’re wanting to use a Twitch ID you’ve used users.twitchUserId, which if users is an array will mean that’s undefined.

I believe what you intended was to use affiliate.twitchUserId which would be the ID of each user in that array.

my bad that was a typo on affiliates. that call goes off successfully with twitch returning to the callback.

ill update my post with the structure. its basically the userId and the username.

once subscribed i think i read that it keeps the subscription active for 10 days?

If your logging is showing that each ID is correctly be used, you can use the Get Webhook Subscriptions endpoint to ensure that the subscriptions are there

If they are not listed on that endpoint then the subscription has either expired, or wasn’t created due to an error, such as not completing one of the subscription steps.

Webhook Subscriptions last up to 10 days, but you’ve set your lease_seconds to 10000 seconds (so a little under 167 minutes)

1 Like

might be the lease time, ive increased it now, so will just monitor it and see that it all works, thanks.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.