Eventsub may not trigger

Is there a particular reason why the events sub may not always trigger?

I have a bit of code that keeps a log of all of the events, and note that sometimes it’s simply not being noted.

Say if someone subs or cheers, whether or not it actually triggers my code, I’d still expect it to appear in my log, even if the channel is offline.

On one occasion it stopped working entirely until I reconfirmed my permission by clicking that Twitch permission button. I’d like it to work consistently.

Do the eventsubs expire? I have the code set up where it will run a quick check to see what permissions are already in place, and then subscribe to those that are new. Should I just have it attempt to subscribe to everything every time the code is loaded?

Moderators note: moved your reply to a new thread.

This suggets that the permission/clientID was revoked from access.

So the eventsub stopped as the permission to read priviledged events was revoked.

No.

They will die if the callback doesn’t work multiple times.
Or the permission to read priviledge data is revoke (subscribers/cheer etc)

A revoke can occur from the user manually revoking it via

or from a password reset. There are also a number of other things that can cause a revoke

This suggests that your code is not always loaded?
If an event fires and the callback is not running, enough dead callbacks and the subscription will self disable.

Sorry, I may be confusing things.

As it’s based on your code from the previous topic, it’s constantly running as it’s on the server. Twitch will contact my index file when an event fires, and the index will return the callback.

I was interested in the way in which you created the log, so I based my code from that.

When an event is triggered, it will add it to a log. Then when I use my program, it will download that log, check if there are any events, and then act upon them. Once actioned, it will clear the log, ready for the next event to be triggered.

While it’s doing this, it also populates a log that is never cleared, so if I note a subscription or cheer that didn’t generate a response, I can check the second log to see if it was event generated.

Most of the time, when something doesn’t occur, it has not been logged… which doesn’t make sense to me.

I have never personally revoked permission or access (including changing the password), so I guess it’s happening at another point that I’m not seeing.

If my code is offline, and I were to run a channel point redemption or something, I can see the log being updated most of the time.

As I said, when my program loads up, it checks that all of the correct events have been subscribed to, then, if it finds one that isn’t, it posts the missing eventsub to api.twitch.tv/helix/eventsub/subscriptions.

Is this wrong?

no thats correct.

If a given subcription is “Dead” and it wasn’t deleted by you
Then it should be presented in the list with a non enabled “status flag” which will help describe the problem.

These error states hang around for 10 days

If the subscription is not present at all then you deleted the subscriptions
if the subscription is present and state enabled then all good
if the subscription is present and state not enabled then the state describes the problem that caused the subscription to die.

You can’t create an active subscription with the same callback and topic.
So this suggests you deleted the subscription (or it died and it’s still in the list with it’s death reason)

This is assuming you are not using something like ngrok. as ngrok free, the tunnel doesn’t exist forever, it’ll reset and assign a new URL after an amount of time.

I’ll have a look at the error states, but at the moment I’m doing the following:

if ($headers['twitch-eventsub-message-type'] == 'notification') {
            // lets parse the data from the notification into an object
                        mylog('Notification!');
            $data = json_decode($raw_data);
            // and check the data parse
            if (json_last_error() == JSON_ERROR_NONE) {
                // we passed all the checks
                // tell Twitch it's OK
                echo 'Ok';
                // and now do something with the $data
                notes(file_get_contents('php://input'));
                // $data is an object, not an array

                // end doing something with the $data
                exit;
            }
        }

Ideally I’d love to be able to split the event logs up, so all of the cheers get put into one, and the subs get put in the other, but as always… not a coder… I have no idea how to check the contents of the data before I start posting the logs.

You could use the header of twitch-eventsub-subscription-type as part of the file name to write to

notes(file_get_contents('php://input'));

(also no need to do php://input again when the data you need is in $raw_data already)

becomes

file_put_contents(__DIR__ . '/' . $headers['twitch-eventsub-subscription-type'] . '.log', $raw_data. "\n", FILE_APPEND);

roughly speaking.

That’ll then generate a log file for each subscription type

Oh thanks, I’ll give that a go!

Yeah, that’s worked. In a similar manner, is there an easy way to grab the “broadcaster_user_name” seeing as it’s not actually a Header?

Meaning it will generate logs based on the name?

*update - Really, what I’d like to do is have the log named after the broadcaster_user_name.

Also, is there a way to find out which channels have granted permission and which has specifically revoked permission?

Pull the field from the data instead of the headers

The vlidate endpoint will return scopes for a given user access token.

You cannot arbitarily get the scopes your ClientID has for a given user ID

See this uservoice

Grant will tell you when any grant occurs, but not the scope

user.authorization.revoke will let you know when all scopes die

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