# CloudFront error on EventSub event subscription attempts

**URL:** <https://discuss.dev.twitch.com/t/cloudfront-error-on-eventsub-event-subscription-attempts/61226>\
**Category:** API\
**Created:** [September 17, 2024, 2:50pm UTC](https://discuss.dev.twitch.com/t/cloudfront-error-on-eventsub-event-subscription-attempts/61226 "2024-09-17T14:50:22Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![SirSilverStar](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/sirsilverstar/32/29852_2.png) [@SirSilverStar](https://discuss.dev.twitch.com/u/SirSilverStar)\
**Post date:** [September 17, 2024, 2:50pm UTC](https://discuss.dev.twitch.com/t/cloudfront-error-on-eventsub-event-subscription-attempts/61226/1 "2024-09-17T14:50:22Z")

</div>

Since yesterday, I’ve been getting the following error returned from CloudFront when attempting to subscribe to events via EventSub:

```auto
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>400 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Bad request.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
<BR clear="all">
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: -TSEMQNPYUCSKqXaVPLcIpz2qjVbEZeYcq0CjQJyb9saJPLQQh1RGA==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>

```

I’m running this in NodeJS using NGROK to handle the SSL stuff so I can keep the bot local. After every stream I unsubscribe from all events so I don’t waste resources and subscribe again for new streams. Here’s the area of code throwing the error with a comment on the appropriate line:

```auto
app.post('/createWebhook', (request, response) => {
    let createWebhookParameters = {
        host: "api.twitch.tv",
        path: "helix/eventsub/subscriptions",
        method: 'POST',
        headers: {
            "Content-Type": "application/json",
            "Client-ID": configuration.API_KEY,
            "Authorization": "Bearer " + access_token
        }
    };

    let createWebhookBody = {
        ...eventTypesConfig[request.query.eventType],
        "transport": {
            "method": "webhook",
            "callback": ngrokURL + "/twitchwebhooks/callback",
            "secret": configuration.TWITCH_SIGNING_SECRET
        }
    };

    let responseData = "";
    let webhookRequest = https.request(createWebhookParameters, (result) => {
        result.setEncoding('utf8');
        result.on('data', function (data) {
            responseData = responseData + data;
            console.log(responseData);
        }).on('end', function (_result) {
            try {
                let responseBody = JSON.parse(responseData); // <--- This is expecting JSON but receiving the HTML error
                response.send(responseBody);
            }
            catch (error) {
                console.log(error);
            }
        })
    });

    webhookRequest.on('error', (error) => {
        console.log(error);
    });
    webhookRequest.write(JSON.stringify(createWebhookBody));
    webhookRequest.end();
});

```

I’ve been using this code for a few years now with no issues. I’ve looked to see if EventSub has been updated and see nothing unusual. I’ve updated my local self-signed certificates in case they expired. No core functionality has changed. Am I missing something new? What should I try next?

Here’s the full implementation of my EventSub functionality I built: [GitHub - SilverStar07/Twitch-EventSub-Full-Implementation](https://github.com/SilverStar07/Twitch-EventSub-Full-Implementation)

Please let me know if you need more information! Thank you so much!

---

<div class="post-metadata">

**Author:** ![SirSilverStar](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/sirsilverstar/32/29852_2.png) [@SirSilverStar](https://discuss.dev.twitch.com/u/SirSilverStar)\
**Post date:** [September 18, 2024, 2:42pm UTC](https://discuss.dev.twitch.com/t/cloudfront-error-on-eventsub-event-subscription-attempts/61226/2 "2024-09-18T14:42:40Z")

</div>

Some new information. Last night after stream, I noticed a new error in relation to this that might help with troubleshooting:

Error: 50630000:error:0A000119:SSL routines:ssl3\_get\_record:decryption failed or bad record mac:c:\ws\deps\openssl\openssl\ssl\record\ssl3\_record.c:623:

This is making me wonder if something is off with my self-signed certificate, but it worked fine before and I’ve already tried generating a new one. I’ll keep researching while waiting for a potential response here. Hope y’all are having an excellent day!

---

<div class="post-metadata">

**Author:** ![ginovva320](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/ginovva320/32/12086_2.png) [@ginovva320](https://discuss.dev.twitch.com/u/ginovva320)\
**Post date:** [September 18, 2024, 11:14pm UTC](https://discuss.dev.twitch.com/t/cloudfront-error-on-eventsub-event-subscription-attempts/61226/3 "2024-09-18T23:14:18Z")

</div>

Are you able to reproduce this with a CURL request?

---

<div class="post-metadata">

**Author:** ![SirSilverStar](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/sirsilverstar/32/29852_2.png) [@SirSilverStar](https://discuss.dev.twitch.com/u/SirSilverStar)\
**Post date:** [September 19, 2024, 3:51am UTC](https://discuss.dev.twitch.com/t/cloudfront-error-on-eventsub-event-subscription-attempts/61226/4 "2024-09-19T03:51:54Z")

</div>

The following CURL command does allow me to subscribe to an event (sensitive info is replaced by \*\*\*)

```auto
curl -X POST https://api.twitch.tv/helix/eventsub/subscriptions 
-H "Content-Type: application/json" 
-H "Client-ID: ***" 
-H "Authorization: Bearer ***" 
-d "{\"type\":\"channel.update\",\"version\":\"2\",\"condition\":{\"broadcaster_user_id\":\"38400240\"},\"transport\":{\"method\":\"webhook\",\"callback\":\"https:// ***/twitchwebhooks/callback\",\"secret\":\"*** \"}}"

```

Considering it works in CURL, why does it break in my code when it worked just fine before? I’ve made no changes to the connection functionality. Thank you for your help!

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [September 19, 2024, 4:27pm UTC](https://discuss.dev.twitch.com/t/cloudfront-error-on-eventsub-event-subscription-attempts/61226/5 "2024-09-19T16:27:38Z")

</div>

> [@SirSilverStar](#):
>
> Considering it works in CURL, why does it break in my code when it worked just fine before? I’ve made no changes to the connection functionality. Thank you for your help!

This sounds like your program is using a different build of curl and/or it’s selections of certs and/or not using the onboard system curl to make requests.

---

<div class="post-metadata">

**Author:** ![SirSilverStar](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/sirsilverstar/32/29852_2.png) [@SirSilverStar](https://discuss.dev.twitch.com/u/SirSilverStar)\
**Post date:** [September 19, 2024, 4:30pm UTC](https://discuss.dev.twitch.com/t/cloudfront-error-on-eventsub-event-subscription-attempts/61226/6 "2024-09-19T16:30:19Z")

</div>

After pursuing ginovva320’s question and discovering how to make a connection with CURL, I decided to try shifting my connection logic to Axios instead of pure JavaScript to see what would happen and it correctly subscribes to events using Axios. The relevant code that’s currently working for me is below in case anyone faces the same problem:

```auto
axios.post("https://api.twitch.tv/helix/eventsub/subscriptions",
        {
            ...eventTypesConfig[request.query.eventType],
            "transport": {
                "method": "webhook",
                "callback": ngrokURL + "/twitchwebhooks/callback",
                "secret": configuration.TWITCH_SIGNING_SECRET
            }
        },
        {
            headers: {
                "Content-Type": "application/json",
                "Client-ID": configuration.API_KEY,
                "Authorization": "Bearer " + access_token
            }
        })
        .then(webhookResponse => {
            console.log(`Axios webhook connected for ${request.query.eventType}`);
        })
        .catch(webhookError => {
            console.log(`Axios webhook error for ${request.query.eventType}:`,
                "-- Error name:", webhookError.name,
                "-- Error message:", webhookError.message);
        });

```

While I’m glad it’s connecting again, I’d still love to know why my original code no longer works after being unchanged and functional for about two years. If anyone has ideas on that, I’d be eager to hear them both for my own learning as well as anyone else’s.

Thanks again! If this continues to work for my next stream or two, I’ll mark this post as the solution.

---

<div class="post-metadata">

**Author:** ![SirSilverStar](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/sirsilverstar/32/29852_2.png) [@SirSilverStar](https://discuss.dev.twitch.com/u/SirSilverStar)\
**Post date:** [September 19, 2024, 4:34pm UTC](https://discuss.dev.twitch.com/t/cloudfront-error-on-eventsub-event-subscription-attempts/61226/7 "2024-09-19T16:34:48Z")

</div>

> This sounds like your program is using a different build of curl and/or it’s selections of certs and/or not using the onboard system curl to make requests.

Interesting. I didn’t know you could have different builds of CURL running simultaneously. How can I see what my program is using vs the system?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [September 19, 2024, 4:49pm UTC](https://discuss.dev.twitch.com/t/cloudfront-error-on-eventsub-event-subscription-attempts/61226/8 "2024-09-19T16:49:28Z")

</div>

> [@SirSilverStar](#):
>
> I decided to try shifting my connection logic to Axios instead of pure JavaScript to see what would happen and it correctly subscribes to events using Axios.

Why axios when fetch is built in (to both browsers and nodeJS)?

> [@SirSilverStar](#):
>
> How can I see what my program is using vs the system?

Since you used pure `https.request` it probably doesn’t know where to look for the certification bundle, and it’s not in the default place or even the onboard/built in to your OS stuff. Or you didn’t update node and the certs that remote are using cannot be verfified by your system, or remote uses new certificate types that your node doesn’t understand.

[node.js - How to add custom certificate authority (CA) to nodejs - Stack Overflow](https://stackoverflow.com/questions/29283040/how-to-add-custom-certificate-authority-ca-to-nodejs) has some thoughts/suggestions on this.

And [curl - SSL CA Certificates](https://curl.se/docs/sslcerts.html) tallks about where the cert bundle lives.

---

<div class="post-metadata">

**Author:** ![SirSilverStar](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/sirsilverstar/32/29852_2.png) [@SirSilverStar](https://discuss.dev.twitch.com/u/SirSilverStar)\
**Post date:** [September 19, 2024, 5:37pm UTC](https://discuss.dev.twitch.com/t/cloudfront-error-on-eventsub-event-subscription-attempts/61226/9 "2024-09-19T17:37:59Z")

</div>

> [@BarryCarlyon](#):
>
> Why axios when fetch is built in (to both browsers and nodeJS)?

Really, force of habit from building projects prior to fetch being implemented natively into Node. That, and I kind of forgot it was, in fact, natively implemented later. I should probably move everything to fetch sooner or later to save having an extra npm package 😅

> [@BarryCarlyon](#):
>
> Since you used pure `https.request` it probably doesn’t know where to look for the certification bundle, and it’s not in the default place or even the onboard/built in to your OS stuff. Or you didn’t update node and the certs that remote are using cannot be verfified by your system, or remote uses new certificate types that your node doesn’t understand.

Great point! What gets me is why it worked just fine one day and not the next. Perhaps the CA store default was switched in a Node update or something? 🤔 Regardless, you reminded me to add my self-signed certificates to Windows, as I’m pretty sure I forgot that when setting up my current rig. Thank you, sir, and for the additional information! You’re a legend!

---

<div class="post-metadata">

**Author:** ![ginovva320](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/ginovva320/32/12086_2.png) [@ginovva320](https://discuss.dev.twitch.com/u/ginovva320)\
**Post date:** [September 20, 2024, 10:13pm UTC](https://discuss.dev.twitch.com/t/cloudfront-error-on-eventsub-event-subscription-attempts/61226/10 "2024-09-20T22:13:33Z")

</div>

Glad you got it working.

As far as what happened, we are always making changes and updates in the background. My guess is that an update to the TLS security policy of our CDN was incompatible with your local node setup. I’m sure Barry’s on the right track with it being cert bundle related.

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [October 20, 2024, 10:14pm UTC](https://discuss.dev.twitch.com/t/cloudfront-error-on-eventsub-event-subscription-attempts/61226/11 "2024-10-20T22:14:11Z")

</div>

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