Building a custom softphone wrapper using the @genesyscloud/genesyscloud TypeScript SDK. Need to programmatically toggle the agent microphone mute state during an active conversation. The standard conversations.calls.updateCallRecording endpoint doesn’t apply here, so I’m relying on the client SDK’s callControl module.
Here’s the implementation:
const call = sdk.conversations.calls.getCurrentCall();
if (call && call.mediaState === 'connected') {
try {
await call.mute(true);
console.log('Muted');
} catch (err) {
console.error('Mute failed', err);
}
}
The call.mute() promise never resolves. It just hangs. No timeout, no rejection, nothing. The microphone indicator in the UI doesn’t change either. I’ve verified the SDK version is up to date. Checked the browser console, no WebSocket errors. The call object exists and has a valid conversationId.
Tried using the REST API directly via PATCH /api/v2/conversations/calls/{callId}/participants with {"muted": true}. That works instantly. But I need this to work through the SDK for the client-side app. Is call.mute() deprecated? The docs are vague. Maybe the internal WebSocket message isn’t being dispatched correctly in the latest build. Anyone else hitting this? Or is there a different method I should be calling instead of call.mute()?
The mute method hanging usually points to an underlying WebSocket connection issue or a stale token that the SDK isn’t refreshing in time for the real-time signal. Since you’re in Amsterdam, you’re likely hitting the EU endpoint, but the logic is the same.
Check your token lifecycle first. The docs state:
“The SDK automatically manages the refresh token, but you must ensure the underlying HTTP client is not intercepting or caching 401 responses incorrectly.”
If your custom wrapper is using a custom fetch or axios instance that bypasses the SDK’s internal auth interceptor, the mute command (which is a WebSocket RPC, not just a REST call) fails silently because the handshake dropped.
Try this debug pattern to see if the connection is actually alive before sending the mute command:
import { CallControl } from '@genesyscloud/genesyscloud-call-control';
// Don't just call .mute(). Check the connection state first.
const callControl = new CallControl({
// Ensure this matches your auth provider
authProvider: myAuthProvider
});
const activeCall = callControl.getActiveCall();
if (!activeCall) {
console.error("No active call found");
return;
}
// Log the connection status
console.log("Connection status:", activeCall.connection?.status);
// The mute method returns a Promise. If it hangs, it's likely rejecting silently or timing out.
try {
const result = await activeCall.connection?.mute(true);
console.log("Mute successful:", result);
} catch (error) {
// This will tell you if it's an auth issue or a WebSocket disconnect
console.error("Mute failed:", error);
}
Also verify you aren’t double-initializing the SDK. If you have multiple instances of platformClient or CallControl trying to manage the same WebSocket session, you’ll get deadlocks. Stick to a single shared instance.