The Twilio Client JavaScript SDK has been renamed to Twilio Voice JavaScript SDK.
Twilio Voice JavaScript SDK lets you select the specific Twilio data center edge locations used when your Twilio Device connects to Twilio. Network communication to and from Twilio will originate/terminate from the fixed, static IP address ranges listed for each edge location. Refer to these ranges if you need to configure your local network to allow communication or apply Quality of Service routing rules to communication with Twilio.
Twilio edge locations were added in version 1.11. Prior releases used a parameter named region
that has now been deprecated.
By default, the Twilio Voice JavaScript SDK will use Twilio's Global Low Latency (the roaming
edge location) routing capability to determine which data center is closest to your user, establishing a connection through Twilio's nearest point of presence.
Global Low Latency uses latency-based DNS lookups to determine the nearest data center. You may want to override this in some cases, especially when your users are working from a fixed location and using a DNS server in another edge location.
GLL (roaming
edge location) requires the upstream DNS to support RFC 7871. See GLL requirements for more information.
If you are operating a restricted network that requires allowing of media IPs, our recommendation is to specify the edge location in your application. Twilio will continue to expand our Global Low Latency (the roaming
edge location) footprint in the future by adding more edges with different IP ranges and leaving the edge selection up to Global Low Latency could result in connections being established to edges that are not allowed by your infrastructure which may result in one-way audio or call set up failures.
Use any one of the available edge locations as the edge
parameter. Leaving the value undefined will cause Twilio to default to its Global Low Latency routing, which cause the Device
to establish its connection to the Twilio edge closest to the user.
For connectivty and bandwidth requirements including IP address list and ports see Voice Platform SDKs' Network Connectivity Requirements
The examples below show two methods for setting an edge location.
Option 1 instantiates a new Twilio.Device
with token
and options
arguments.
Option 2 instantiates a new Twilio.Device
without the options
argument. With this method, you can update the device
options with device.updateOptions(options)
.
Option 1:
_10const device = new Twilio.Device(token, { edge: "dublin" });
Option 2:
_10const device = new Twilio.Device(token);_10device.updateOptions({ edge: "dublin" });
Option 1:
_10const device = new Twilio.Device(token, { edge: "ashburn-ix" });
Option 2:
_10const device = new Twilio.Device(token);_10device.updateOptions({ edge: "ashburn-ix"});
_10const device = new Twilio.Device(token);
By default, the SDK automatically reconnects the WebSocket connection to the same edge location when it is unreachable, or when the SDK encounters a network error that results in a WebSocket disconnect. But if Twilio.Device.Options.edge
parameter is supplied as an array of edge names, the SDK will enable automatic Edge fallback functionality. The diagram below illustrates the logic that is executed to perform the fallback.