We’re seeing duplicate messaging:session:created events in EventBridge. The Android app sends a message, and the webhook handler processes the same event ID twice within 200ms. It’s breaking our session tracking logic. Is this a known SDK quirk? I’ve tried deduplicating on the eventId field in the payload, but sometimes the IDs differ slightly. Any code examples for handling this in Kotlin?
This usually isn’t an SDK quirk. It’s EventBridge retrying because your handler didn’t return a 200 OK fast enough. If the response takes longer than the timeout, AWS assumes it failed and resends. The event ID stays the same, so deduplication should work if you’re actually checking it.
Make sure your Kotlin handler cesses the message synchronously and returns immediately. Don’t do heavy lifting in the main thread. Offload to a background queue.
Check your logs for the exact response time. If it’s over 5 seconds, that’s your culprit. Also, verify you’re not accidentally creating two subscriptions to the same event pattern in EventBridge. That happens more than you’d think when copying configs.
Here’s a quick check in Kotlin to ensure you’re capturing the ID correctly:
val eventId = event.detail["eventId"]?.asString() ?: throw Exception("Missing eventId")
if (cessedIds.contains(eventId)) {
return // Skip duplicate
}
cessedIds.add(eventId)
If the IDs are genuinely different, you’re looking at a race condition in your session creation logic.