Extension pubsub: duplicate messages

Hi, we have a question regarding extension pubSub System:

If we send a message to your API with targets set to [“broadcast”], this message will get delivered two times to the extension. The callback is always called two times.
We are sure that our EBS sends the message only one time to the Twitch PubSub API.
Our logs say that only one https-connection with the message is established.
It is send the following way:

  • target URL: https://api.twitch.tv/extensions/message/
  • JSON POST Request: {‘content_type’: ‘application/json’, ‘message’: ‘{…}’, ‘targets’: [‘broadcast’]}
  • headers: {‘Client-ID’: …, ‘Authorization’: ‘Bearer …’}

Is something wrong with this call?

Can you include a full example payload/call that you are sending with secrets omitted.

We have different messages. One exact example is:

  • target URL: https://api.twitch.tv/extensions/message/[channel_id]
  • JSON POST Request: {‘content_type’: ‘application/json’, ‘message’: ‘{“event”: “newOnlineState”, “data”: {“online”: 1}}’, ‘targets’: [‘broadcast’]}
  • headers: {‘Client-ID’: [client_id], ‘Authorization’: ‘Bearer [token]’}

Do you think it has something to do with the content? I suggest that the content does’nt matter.

The API call on EBS looks so (python):

def Send(self, channelId, event, data, targets = [“broadcast”]):
headers = {
“Client-ID”: CLIENT_ID,
“Authorization”: “Bearer %s” % (self.GenerateJWT(channelId), ),
}
messageData = {‘event’: event, ‘data’: data}
httpData = {“content_type”: “application/json”, “message”: json.dumps(messageData), “targets”: targets}
pubSubURL = “https://api.twitch.tv/extensions/message/%s” % (channelId, )
result = requests.post(pubSubURL, json = httpData, headers=headers)

and the call in the extension is:

window.Twitch.ext.listen(“broadcast”, pubsubMsg);

The pubsubMsg function is called twice, during the Send function on EBS side is called once.

Perhaps which is why I asked. Your call seems ok.

Where in your extension is the listen call?

Are you doing something like, what I’ve done before and caused your listen to be called more than once? As per:

I ended up having my listen callback called four times. A listen being called inside onAuthorized causes unpredictable results and/or multiple listeners being bound.

Exactly that is what I do - I call the listen function inside onAuthorized callback.

I putted it outside now and now it works.
This looks like a bug on twitch side. Maybe it makes sense to provide this constrain in the documentation or just solve the bug :slight_smile: (seems to be an old bug)

Thanks a lot for your help.