Troubleshooting Common Problems with the Twilio Voice JavaScript SDK

In this article you will find troubleshooting steps for resolving some of the most common problems we see for apps built using the The Twilio Voice JavaScript SDK (formerly "Twilio Client"). This guide covers the following issues:

Notice: Prior to going live with a Twilio Voice JS SDK application, we recommend reviewing the following checklist:

  • Open network ports in your router / firewall / antivirus software. For full details, see Voice SDKs Network Connectivity Requirements.
  • If your router supports QoS, prioritize the ports mentioned above, or the IP address of the computer(s) making Voice SDK calls.
  • Run the test at http://networktest.twilio.com. This will test two-way audio, and report how many simultaneous calls your connection can support.

For more information, see Twilio Voice JavaScript SDK Deployment Best Practices.

Unable to establish a call

  • Check open network ports in your router / firewall / antivirus software
  • Confirm a network connection is currently available
  • Review the javascript console for application errors

No audio or one-way audio

  • Check open network ports in your router / firewall / antivirus software
  • Confirm the hardware is correctly attached and ensure the correct microphone and speakers are selected in software settings
  • Check to ensure the microphone is not muted (some have a hardware mute button) and the speaker volume is turned up

Call audio cutting out or stops transmitting

  • Twilio Voice requires a high speed and low latency network connection. Benchmark the network by testing your throughput and ping at speedtest.net and aim to improve the scores.
  • Enable router QoS or prioritize traffic for Twilio Voice.
  • Reduce network activity not related to VoIP or use a separate network for VoIP workstations.
  • Try using a wired connection or move closer to your wi-fi router or base station. Connection jitter or packet loss can produce choppy or "robotic" sounding call audio.

Call audio is garbled or contains artifacts

  • Use a headset instead of built in computer microphone.
  • Reduce ambient noise such as nearby speakers or fans.
  • Adjust the distance of the microphone from the mouth - too close can cause audio clipping.
  • Adjust microphone levels in the computer’s sound settings.
  • Ensure computer has resources available to process a call.
    • CPU and RAM are not over-utilized
    • Close un-needed applications and browser tabs
    • Try disabling antivirus software
  • Try using a wired connection or move closer to your wi-fi router or base station. Connection jitter or packet loss can produce choppy or "robotic" sounding call audio.

Microphone level is changing on its own

Some device drivers do not behave properly for auto-gain control. If you have noticed that your microphone level is self-adjusting, consider overriding the WebRTC defaults in order to force the AGC to be turned off, regardless of system wide settings. You can do this by specifying googAutoGainControl when calling the setup function, as follows:

Twilio.Device.setup(token, {
    audioConstraints: {
        mandatory: { 
            googAutoGainControl: false 
        } 
    } 
});

For the complete list of audioConstraints, please refer to the FAQ How to constrain the audio sources in Google Chrome?.

Logging

If you are having issues with how your application is operating, we highly recommend debug level logging and suggest enabling it if you have not already done so.

When using the Twilio Voice JavaScript SDK Quickstart for example, debugging is enabled by default. To see this in the code, open your file Quickstart.js, and find the text “loglevel: 1”, on Line 68, under the Twilio.Devicefunction.

Your code should look something like this:

   // Instantiate a new Twilio.Device
  function intitializeDevice() {
    logDiv.classList.remove("hide");
    log("Initializing device");
    device = new Twilio.Device(token, {
      logLevel:1,

Once this is enabled, when you run or execute your application, you should see a breakdown of additional logging information about your session within the browser console.

Web console logging for the Twilio Programmable Voice SDK

This can be useful in debugging your application as you can see what is occurring throughout your application, as it occurs. We also have an article on JS logging for your reference.

Furthermore, we offer a Preflight API which represents a test call to Twilio which provides information to help troubleshoot call-related issues when using the Voice JavaScript SDK.

To learn more please see :Twilio PreFlight API

In general, when raising a ticket with Support it is important to always have the most information available. Supplying your Application logs to us will greatly reduce the resolution time of your ticket and allow our agents to investigate faster.

For Android and iOS, you can enable logging as seen below:

Android (Java):

 //Set Log level
Voice.setLogLevel(LogLevel.DEBUG);

iOS (swift):

 TwilioVoiceSdk.logLevel = .debug

Notice: Please save your log files as .TXT when sending to support. For security reasons, please refrain from sending .ZIP files.

Additional Resources

Have more questions? Submit a request
Powered by Zendesk