Issue:
I am experiencing an issue where
twitch.ext.listen("broadcast", function(){})
fails to fire ~80% in my app after an update to EBS.
Details:
Using the network tab of the developer tools, I deduced (hopefully correctly) that my EBS broadcast function, request('https://api.twitch.tv/extensions/message/${channelId}')
, is responsible for causing the GET wss://pubsub-edge.twitch.tv/v1
requests to occur. And I believe the requests wss://pubsub-edge.twitch.tv/v1
are what causes the twitch.ext.listen
function to sometimes fire.
It seems like the 20% when twitch.ext.listen("broadcast", function(){})
successfully fires, the “Frames” tab of the GET wss://pubsub-edge.twitch.tv/v1
request looks like this, where MESSAGE is included as a list item:
However, when twitch.ext.listen("broadcast", function(){})
fails to fire, the Frames" tab of the GET wss://pubsub-edge.twitch.tv/v1
request looks this (note MESSAGE is missing):
Anybody know what the issue is here? I notice that the MESSAGE takes a lot more time to complete/fire. Is there a way I can “wait” for it somehow or speed up its response time? Thanks.
More Information on my Extensions: (not sure if this info is necessary.)
In my frontend code, in App.js, I set up the listener in componentDidMount like so
(It is almost identical to the one used here in extensions-boilerplate):
componentWillMount() {
if (this.twitch) {
this.twitch.listen("broadcast", function(){})
}
}
After making any update calls to my backend, I make sure to call my sendBroadcast
function so I can get the listener to run.
Here is what my EBS sendBroadcast
function looks like (It is almost identical to the one used here in extensions-hello-world):
function sendBroadcast(channelId) {
// Set the HTTP headers required by the Twitch API.
const headers = {
"Client-ID": clientId,
"Content-Type": "application/json",
Authorization: bearerPrefix + makeServerToken(channelId)
};
// Create the POST body for the Twitch API request.
const body = JSON.stringify({
content_type: "application/json",
message: store[channelId],
targets: ["broadcast"]
});
// Send the broadcast request to the Twitch API.
request(
`https://api.twitch.tv/extensions/message/${channelId}`,
{
method: "POST",
headers,
body
});
}