ImagineOn avatar image
ImagineOn asked

How to solve "Server is unresponsive" displayed in the alexa app?

Hey folks,
I am back again with another problem. After googling and browsing this forum for a sane amount of time while finding no solution, I thought it would be best to write another post since I got a quick response on the last one. Which was of course greatly appreciated!

Since the last post I implemented sync ReportState aswell as Discovery responses.
The device itself now acts fine and I can issue voice commands without any problem.
However, after some non-deterministic amount of time (about one to five hours) the app shows the message "server is unresponsive". Disabling the skill and reactivating it removes the "error" and everything works normal for a decent amout of time again.

Even more strange is that, even with the app open, there are no request sent to the lambda function.Which means even if I wanted to answer requests there are no requests to actually answer since the lambda function is not receiving any messages.

Furthermore, since the alexa-app to lambda function communication is totaly out of my control I am afraid I am lost on this one.

Could someone point me to some information what could be the reason for the app to render "Server is unresponsive?"

Some more information that might be helpfull:
- I still send ChangeReport messages async
- I added the endpoint health trait as can be found in the other post

Help is greatly appreciated,

Kind regards,

alexaalexa smart homesmart home
10 |5000

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

KirkC@Amazon avatar image
KirkC@Amazon answered

Hello Kevin. To start, is the Discover.Response JSON that you're referring to the same as that which was posted in your previous question?

The reason that I ask is that I was able to take the "endpoints" array, which defines the "OLX3" air purifier device, and used that in my own test skill to successfully discover the device. Then, on the "Devices" tab of the Alexa app I tapped on the "OLX3" device to confirm that my skill's back-end Lambda function was receiving a "ReportState" directive every three seconds as one would expect.

Thus, insofar as there is an issue, my initial inclination it that it doesn't have to do with the Discover.Response JSON itself

Next, this comment caught my attention though:

Disabling the skill and reactivating it removes the "error" and everything works normal for a decent amount of time again.

This to me suggests an issue with the skill's account linking implementation. Specifically, that after a user completes account linking, your OAuth server is supposed to provide Amazon with both an access token and a refresh token.

The access token is included in skill requests sent to your skill's back-end, whereas, the refresh token is used by Amazon to get new access tokens from your OAuth server before the access token expires.

If however, the refresh token provided is invalid, or the OAuth server cannot exchange the refresh token for a new auth token, then any skill functionality that requires a valid access token will begin to cease functioning after the access token expires. That is, until the user disables the skill and re-performs account linking again to start the process over.

Indeed, in our Alexa Account Linking Debugging Tips knowledgebase article we have a section titled "Account linking succeeds, but after some time the customer has to link accounts again".

The most common cause of which of which is that "Alexa was unable to use the provided refresh token to grab a new access/refresh token pair." We have the following recommended actions to resolve this:

  1. Ensure that the access token time to live (TTL) is more than 5 minutes.
  2. Ensure that your authorization server can successfully refresh the access/refresh token pair when presented with a refresh token by Alexa.
  3. Ensure that you are not invalidating refresh tokens too early - Alexa may take some time after the access token has expired to refresh the token, and if your authorization server has already invalidated the refresh token, Alexa will not be able to refresh the access/refresh token pair and your customer will have their account linking disabled. More details here:

10 |5000

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

ImagineOn avatar image ImagineOn commented ·

Hey KirkC
This sounds like a very good observation.
Thank you for the insight and the links regarding account linking debugging tips.
I will check this as soon as possible.
(However, since I am not responsible for the OAuth provider part this might take some days)

Appreciated the help!
Best regards

1 Like 1 ·
ImagineOn avatar image ImagineOn commented ·

Hey KirkC (and everbody else who might read this),
You were very correct with your obersavation regarding the refresh token.

Our OAuth provider did not issue a refresh token without setting a scope to request a refresh token at all. So there was never a refresh token that could be used in order to get a new access token.

It feels nice to simply (and finally) solve the problem by adding a scope in the alexa skill.

Anyway, Thanks for you help!
Kind regards, Kevin.

PS: Since there was no refresh token at all, could this information be forewarded to the developer that does the debugging somehow? Maybe in the Alexa.Authorization Interface as a warning object in the payload or something. I am in no position to take part in any discussion, just wanted to throw my two cents in here.

1 Like 1 ·
Bogdan avatar image
Bogdan answered

This is what I am looking for thanks.

10 |5000

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