Trying to pipe analytics events to Kafka. Using the Node.js SDK to fetch the token and then hitting the streaming endpoint.
Docs state: “The connection remains open for the lifetime of the access token.”
Here is the basic flow:
const client = require('@genesyscloud/purecloud-auth-client');
async function startStream() {
const auth = new client.OAuthClient({
clientId: process.env.GENESYS_CLIENT_ID,
clientSecret: process.env.GENESYS_CLIENT_SECRET,
domain: process.env.GENESYS_DOMAIN
});
const token = await auth.clientCredentials(process.env.GENESYS_SCOPE);
const headers = {
'Authorization': `Bearer ${token.accessToken}`,
'Accept': 'application/json'
};
const res = await fetch(`https://${process.env.GENESYS_DOMAIN}/api/v2/analytics/events/stream`, {
headers,
method: 'GET'
});
// Pipe res.body to kafka producer...
}
It works fine for about 5 minutes. Then the stream silently stops. No error event on the Node side. Kafka just gets nothing.
I checked the token expiry. It’s valid for another 55 minutes.
Is there a hidden keep-alive requirement I’m missing? Or is the server closing the TCP connection because the analytics payload is too large?