About HTTP/2 Connections with AVS
The Alexa Voice Service (AVS) exposes an HTTP/2 endpoint so that a device can send events to AVS and receive directives from AVS. Read on to learn more about the concepts and requirements for creating and maintaining an HTTP/2 connection between your device and AVS.
Terminology
- Frame – The basic protocol unit in HTTP/2. Each frame has a different purpose, for example, HEADERS and DATA frames which form the basis of HTTP requests and responses.
- Stream – An independent, bidirectional sequence of frames exchanged between a device and server within an HTTP/2 connection. For detailed information, see Streams and Multiplexing in RFC 7540.
- Downchannel – A stream you create in your HTTP/2 connection that delivers directives from AVS to your device. The downchannel remains open in a half-closed state from the device and open from AVS for the life of the connection. The downchannel is primarily used to send AVS-initiated directives and audio attachments to your device.
Codec specifications
The following table shows the codec specifications required for your HTTP2 connection. Note that although increasing the Opus complexity increases processor load, it can also improve performance.
Specification | PCM | Opus
|
---|---|---|
Number of channels |
Single channel (mono) |
Single channel (mono) |
Sample size |
16-bit linear PCM (LPCM) |
16 bit |
Sample rate |
16 kHz |
16 kHz |
Bitrate |
256 Kpbs |
32 Kpbs or 64 Kpbs, hard constant bitrate |
Byte order |
Little endian |
Little endian |
Frame size |
10 ms |
20 ms |
DATA frame size |
320 bytes |
80 bytes (32 Kpbs) or 160 bytes (64 Kpbs) |
Complexity |
N/A |
|
Base URLs
Use the following default base URLs for your AVS HTTP/2 connection:
Base URLs
Region | Supported Countries/Regions | URL |
---|---|---|
Asia | Australia, Japan, New Zealand, India | https://alexa.fe.gateway.devices.a2z.com |
Europe | Austria, France, Germany, Italy, Spain, United Kingdom | https://alexa.eu.gateway.devices.a2z.com |
North America | Canada, Mexico, United States | https://alexa.na.gateway.devices.a2z.com |
Legacy Base URLs
Region | Supported Countries/Regions | URL |
---|---|---|
Asia | Australia, Japan, New Zealand, India | https://avs-alexa-fe.amazon.com |
Europe | Austria, France, Germany, Italy, Spain, United Kingdom | https://avs-alexa-eu.amazon.com |
North America | Canada, Mexico, United States | https://avs-alexa-na.amazon.com |
Best practices for your HTTP/2 connection
Amazon makes the following recommendations for managing and maintaining the HTTP2 connections for your device:
-
Reduce latency – To reduce latency, chunk all captured audio to stream to AVS. The stream should contain 10 ms of captured audio per chunk for Pulse Code Modulation (PCM) or 20 ms for Opus.
Important: Send all captured audio to AVS using either PCM or Opus (using the Opus Speech Encoder) and adhering to the codec specifications in the Codec specifications table. -
Concurrent stream limitations – An HTTP2 connection with AVS supports up to 10 concurrent streams, including event streams, the downchannel, and pings. Make sure to close event streams after receiving responses.
-
Read timeouts – Because AVS requires a downchannel stream to be open between AVS and a device for the life of the connection, set any read timeout for your device to at least 60 minutes.
-
Connection timeouts – If your HTTP2 device has connection pooling or marks connections as idle, adjust the timeout so the connection isn't disrupted. If the connection closes, make sure to complete the flow described for creating a connection, which includes re-establishing the downchannel stream and synchronizing state with AVS. Set the timeout to at least 60 minutes to make sure that your connection doesn't prematurely close.
Related topics
- Create and Manage HTTP/2 Requests with AVS
- Connect to AVS with HTTP/2
- HTTP/2 Message Syntax Reference
Last updated: Apr 07, 2021