Hi,
I have an application which integrates genesys-cloud-webrtc-sdk
via CDN.
SDK CDN link : https://sdk-cdn.mypurecloud.com/webrtc-sdk/v10.0.0/genesys-cloud-webrtc-sdk.bundle.min.js
SDK Version : 10.0.0
The flow of my application :
- Obtain
token
to be used in creatinggenesys-cloud-webrtc-sdk
instance
const sdk = new window.GenesysCloudWebrtcSdk.GenesysCloudWebrtcSdk({
accessToken: token,
environment: environment,
logLevel: "info",
optOutOfTelemetry: true,
useHeadsets: false,
allowedSessionTypes: [window.GenesysCloudWebrtcSdk.SessionTypes.softphone],
});
- Initialize SDK via
sdk.initialize();
- Start a softphone session
const { id, selfUri } = await sdk.startSoftphoneSession({
phoneNumber: dialUpNum,
});
- Listen to
conversationUpdate
events to mark the start of the call and end of the call. - Use
event.current[0]
from theconversationUpdate
and check themostRecentCallState
to beconnected
which is the start of the call - Use
event.removed[0]
from theconversationUpdate
and check themostRecentCallState
to bedisconnected
which is the end of the call - Cleanup within
conversationUpdate
function when call end marked as below
const cleanup = async () => {
if (sdk) {
const activeConversations = sdk.sessionManager?.getAllActiveConversations() || [];
for (const conversation of activeConversations) {
if (conversation?.sessionId) {
// to terminate any session which failed and is still live or active
await sdk.forceTerminateSession(conversation.sessionId);
}
}
await sdk.destroy();
sdk = null;
delete window["GenesysCloudWebrtcSdk"];
}
};
Problem
If after the call starts and before the call ends, if the websocket is disconnected which is handled by disconnected
event on the SDK as below
sdk.on("disconnected", async (info?: any) => {
//sdk wont reconnect automatically, so abandon
const errorMessage = "SDK websocket connection disconnected";
await cleanup();
reject(new Error(errorMessage));
});
The cleanup
method which does sdk.destroy
is expected to "Ends all active sessions, disconnects the streaming-client, removes all event listeners, and cleans up media" which is helpful as the above process repeats for the next call.
However it seen that even though disconnected
event is fired, the WebSocket connection is reconnected post calling and finishing up cleanup
which also should disconnect the streaming-client
The reconnected WebSocket then keeps sending pings to remain alive. Now when the next call is generated by the above process, I receive -- "received a conversation event for a conversation we are not responsible for. not processing
" message in the console which effectively hinders my call flow and the SDK events are not captured. I can see in the network tab that the newly created WebSocket for the new session and the reconnected WebSocket both receive jabber messages for the same conversationId
Is there a way to sort this out ?
- Could it be that the
cleanup
method is not sufficient enough to clean/remove the SDK instance ? how to check if multiple SDK instances are being created ? - Or is it just because of having two streaming-clients (WebSocket) alive at the same time associated to the user ?
Any help or guidance is appreciated. Thanks in advance.