article

Sindy@Amazon avatar image
Sindy@Amazon posted

OkHttp Issues with Alexa Voice Service (AVS)

Summary:

If you are using OkHttp with AVS, and are having issues with timeouts, there may be an issue with your configuration. Every request where you use the ResponseBody a certain way (getting a stream and not closing it) can leave the HTTP2 stream open, and Amazon’s server tells HTTP2 clients to have at most 10 open streams a connection. So after 10 requests (events, DC, and ping all count) your service will start to error out.

There can be a secondary issue with timeouts, and this does apply to everybody. Most libraries have a timeout applied to how long you can attempt to read without actually getting any data. This is especially necessary to get right on the downchannel because it could have long periods of time where nothing is coming down on it, which would hit the timeout, and end the request. The solution is to set no timeout for that. There is also a connection pooling timeout specific to OkHttp that says to close a connection if it's idle after 5 minutes. That specific implementation didn't allow an infinite value, so we suggest setting it to an hour, since the server will close all connections every hour anyways.

Keywords: alexa voice service, okhttp, issues, stream, timeout

KB_0450

alexa voice servicehow-to
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Article

Contributors

Sindy@Amazon contributed to this article