We are running a high-volume campaign and the CXone webhooks are timing out on our endpoint. The platform returns 200 initially, but our server throws a 502 Bad Gateway after 5 seconds. CXone retries three times, then drops the event. We need a dead letter queue strategy because we can’t afford to lose these contact events.
I’m using Node.js with Express. The current handler looks like this:
app.post('/cxone/webhook', async (req, res) => {
try {
await processEvent(req.body);
res.status(200).send('OK');
} catch (err) {
// This is where it fails
console.error('Webhook error:', err);
res.status(500).send('Server Error');
}
});
The problem is processEvent takes too long. I tried setting res.setTimeout(30000) but CXone doesn’t wait that long. It expects a quick acknowledgment.
My plan is to:
- Acknowledge the webhook immediately with 200.
- Push the payload to an SQS queue.
- Have a consumer process the queue.
But I’m worried about duplicate events. CXone retries on 5xx. If I return 200 before the DB commit, I might lose data if the app crashes. If I return 200 after DB commit, I get 502s from CXone.
Is there a way to configure the webhook retry policy in the CXone API? I checked the /api/v2/routing/webhooks endpoint but didn’t see a field for retryCount or deadLetterQueueUrl.
Here is the error log from our side:
[Error: connect ECONNREFUSED 10.0.0.5:443]
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '10.0.0.5',
port: 443
}
Should I be using a message queue like Kafka or just SQS? The volume is about 50k events per hour. I don’t want to build a complex retry mechanism if the platform supports it natively. Any code examples for handling this pattern in Node.js?