EventBridge Consumer - Duplicate Notifications; JWT Validation Issue?

Hey everyone;

So we’ve got this delightful situation where our EventBridge consumer is receiving duplicate notifications for conversation.updated events; it’s happening intermittently, maybe once every 20-30 events; which is fun to debug, naturally. It’s not a simple duplicate - the event ID is different each time, but the underlying conversation and event data are identical; meaning something’s re-triggering the event, or… something.

We’re listening on the WebSocket Notification API, obviously, and the JWT validation seems okay; but I’m starting to suspect there’s a race condition somewhere in the authentication flow. We’re pulling the JWT from the Genesys Cloud SDK for Node.js, version 2.1.0; and validating it locally before establishing the WebSocket connection. The token is refreshed every hour, just in case.

The Architect flow triggering these events is fairly simple; it’s a basic transfer blended campaign with a single disposition, and it’s pushing the conversation.updated event when the call ends. It’s not using any complex data actions or custom properties; or at least, none that should be causing this.

The Lambda handler is doing almost nothing; just parsing the event and logging to CloudWatch. For what it’s worth, we’ve checked the CloudWatch logs for the EventBridge bus itself, and aren’t seeing duplicate events there; which suggests the issue is somewhere between the EventBridge bus and our consumer. Here’s a snippet of how we’re establishing the connection:

const WebSocket = require('ws');
const jwt = require('jsonwebtoken');

// Assume 'token' is a valid JWT from the GC SDK
const ws = new WebSocket('wss://events.gc.genesys.cloud/events/v2/connections');

ws.on('open', () => {
 console.log('WebSocket connection established');
 ws.send(JSON.stringify({
 type: 'authenticate',
 jwt: token
 }));
});

ws.on('message', event => {
 // Parse and process the event
 console.log('Received event:', event);
});

The biggest head-scratcher is why the duplicate events all seem to have the same timestamp; down to the millisecond. It’s like the notification is being sent twice simultaneously. I’m beginning to suspect the WebSocket connection is somehow getting reset and re-established without our handler knowing, leading to re-authentication; but I’m not seeing any disconnect events. Anyone else seen this madness?

1 Like

ran into something kinda similar a while back lol. it’s almost always the event bridge filters tbh.

Quick Check - Event Filters

  1. Double-check your EventBridge rule filters. Are you sure you aren’t accidentally matching events twice? I sometimes get the conversation.updated and conversation.metadata events mixed up. They look kinda same in the logs.

  2. The JWT stuff… hmm. It’s usually a permissions issue. Make sure the role EventBridge is assuming has events.Read permissions for the conversation.updated event type. It’s super easy to miss, especially if you’ve been fiddling with roles.

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "events:Read",
"Resource": "arn:aws:events:YOUR_REGION:YOUR_ACCOUNT_ID:rule/YOUR_EVENT_BRIDGE_RULE"
}
]
}

FWIW, I always test with a super simple filter first (event.type == "conversation.updated") to rule out filter issues. YMMV. And yeah, I can’t find my full logs right now, sorry!

2 Likes

that fix worked; the scope on the EventBridge rule was too broad-it was picking up events from a dev org we didn’t realize was still publishing; narrowing it to our production account solved the duplicate issue; thankfully. it’s always something; isn’t it?