twilio / twilio-voice.js

Twilio's JavaScript Voice SDK
Other
52 stars 53 forks source link

[BUG] TJS instaed of CallSid #265

Open joao-carneiro-twistag opened 4 months ago

joao-carneiro-twistag commented 4 months ago

Code to reproduce the issue:

version: 2.10.2 This issue occurs sporadically and is challenging to reproduce consistently. However, I've observed that the TJS is generated instead of a valid callSid. This seems to be related to the function generateTempCallSid in your repository.

Expected behavior:

Twilio should consistently return a valid callSid whenever a call is made.

Actual behavior:

In approximately 1 out of every 1000 calls, Twilio does not return a valid callSid. Instead, it provides a TJS. I have extensive logs and reports available that can provide further insights into this issue upon request.

Software versions:

joao-carneiro-twistag commented 4 months ago

An example log:

[TwilioVoice][EventPublisher] Publishing insights {"endpointName":"EndpointEvents","event":{"group":"ice-gathering-state","level":"DEBUG","name":"complete","payload":{"aggressive_nomination":false,"browser_extension":false,"dscp":true,"ice_restart_enabled":true,"platform":"WebRTC","sdk_version":"2.10.2","temp_call_sid":"TJSd65c394c-f3f8-4032-8a8d-a625dfb75736","direction":"OUTGOING","region":"EU_FRANKFURT"},"payload_type":"application/json","private":false,"publisher":"twilio-js-sdk","timestamp":"2024-05-09T13:48:54.905Z","publisher_metadata":{"app_name":"XXXXXX","app_version":"0.2.106"}},"host":"XXXXXX"}

Also found this in your sdk.. image

charliesantos commented 4 months ago

A a tempCallSid is used for outbound calls while the call is still trying to connect to Twilio. As soon as the call is established, usually after the ringing event, the real callsid will be returned by Twilio backend and it will be used. What you're seeing is normal.

joao-carneiro-twistag commented 4 months ago

I appreciate your answer. Yes, that makes sense, but, I've encountered an issue on the client side of my application where, in some cases, long-duration calls lasting over 100 seconds do not result in receiving an original CallSid. This seems to occur particularly when calls are not answered. So i end up with a lot of "lost" calls

charliesantos commented 4 months ago

Thanks @joao-carneiro-twistag . I took a look at the example tempCallSid above, TJSd65c394c-f3f8-4032-8a8d-a625dfb75736, it generated a real callSid CA76eaadfa0e73505d9e70b690e3049ad2. Where are you trying to read the real callsid from?

joao-carneiro-twistag commented 4 months ago

Thanks for your help @charliesantos ! I'm always reading it from parameters.CallSid

charliesantos commented 4 months ago

In that log you provided, the call is still trying to connect, so a real callsid is not available if you try to read it. For SDK outgoing calls, try reading it after the call.on('ringing') event or call.on('accept'). For SDK incoming calls, the real callSid is always available.

joao-carneiro-twistag commented 4 months ago

yes its an outgoing call and i'm reading it only after the event 'ringing', i'm afraid it could be due to internet issues, the client might lose the connection between the proccess

or.. i might be elsewhere trying to access the callSid before that event occurs, i'll take a look and come back, thank you for your time!

charliesantos commented 4 months ago

We can also take a look more if you can reproduce the issue and provide the whole debug logs.