startSoftphoneSession Unable to find session error

Hello,

I'm implementing a web based softphone using version 7.3.1 and am having an issue. I'm able to create an outbound dial, but the session is not stored in the WebRTC session manager and thus cannot end the call session.

const resp = await this.rtcSdk.startSoftphoneSession({
  phoneNumber: number
});

The logging shows this piece of information.
[webrtc-sdk] incoming conversation started, but we do not have a session. assuming it was handled by a different client. ignoring

When I attempt to end the conversation, I see:
Error: Unable to find session
at Qt.ue (utils.js:26:19)
at sn.getSession (session-manager.js:94:19)
at sn. (session-manager.js:317:34)
at Generator.next ()
at session-manager.js:7:71
at new E (zone.js:1387:29)
at Le (session-manager.js:3:12)
at sn.endSession (session-manager.js:312:16)
at Qt. (client.js:681:40)
at Generator.next ()

Can anyone provide some insight? Not sure if it's a bug in the SDK or if I need to manage the session.

Hey Devin,

Currently taking a look at this. On first glance it sounds like a proceed is never sent from the client and the pendingSession ends up being cancelled.

If you don't mind, I have a few questions, were you able to actually connect a call or did you just get it to dial? Did you have a conversationId? Could you confirm that you accepted the pendingSession and that a proceed was sent?

A bit of background on that last question of mine:

- In the case of an outbound call, the application initiating the call should
automatically accept the pending session, which should have a conversationId
that matches the conversationId in the response to the request to place the call.
Alternatively, a client designed to handle all outbound call connections can
immediately accept pending sessions for outbound calls. If two such applications
are running simultaneously, there will be a race condition for which instance
actually connects the call audio.

Hello Zach thank you for investigating! I'm not sure about the proceed, but I can confirm I can establish a connection and can hear/talk on both sides of the conversation. But the session manager just doesn't seem to have the call.

When calling startSoftphoneSession, I do have a conversationId returned.

My latest attempt today was to add this snippet of code, "acceptPendingSession" and auto answer when the dialed conversation is presented. I would like to note, that without this new snippet of code, the call was already established, so I don't believe this is needed.

this.rtcSdk.on('pendingSession', event => {
  console.log("pendingSession", event);
  // Auto answer an outbound call.
  const state = this.state.getValue();
  if (event.conversationId === state.dialingConversationId) {
    this.rtcSdk.acceptPendingSession({
      conversationId: event.conversationId,
      sessionType: SessionTypes.softphone
    });
  }
});

When I attempt an outbound dial these are the logs I see using the new snippet of code above.

I probably should have asked this first, but is it possible you have multiple clients open? Or even multiple instances of the WebRTC SDK in your app? If one client/instance accepts a pending session, it'll be removed from the others. Which would explain the error you mention in your first post and explain why there's no pending session to accept.

1 Like

Good catch. :man_facepalming: It appeared the GenesysCloudWebrtcSdk object was constructed twice, and overriding the first instance. The first instance was receiving and handling the calls. The second instance was not seeing the session.

Thank you. This is resolved working now.