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?