Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error after session active > 24 hours #57

Closed
sleuth255 opened this issue Dec 9, 2019 · 13 comments
Closed

Error after session active > 24 hours #57

sleuth255 opened this issue Dec 9, 2019 · 13 comments

Comments

@sleuth255
Copy link

Hello, Alexa-remote won't correctly process speak functions after its been running for > 24 hours. Here are the relevant log entries:

Alexa-Remote: No authentication check needed (time elapsed 33888)
Alexa-Remote: Sending Request with {"host":"pitangui.amazon.com","path":"/api/behaviors/preview","method":"POST","timeout":10000,"headers":{}} and data={"behaviorId":"PREVIEW","sequenceJson":"{"@type":"com.amazon.alexa.behaviors.model.Sequence","startNode":{"@type":"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode","operationPayload":{"deviceType":"AKNO1N0KSFN8L","deviceSerialNumber":"G0B0H506617700D3","locale":"de-DE","customerId":"AWMF3SVYOF8RS","textToSpeak":"hello"},"type":"Alexa.Speak"}}","status":"ENABLED"}
Alexa-Remote: Response: No body
Error: no body
at IncomingMessage. (C:\alexa-speaks\public\alexa-remote.js:767:126)
at IncomingMessage.emit (events.js:215:7)
at endReadableNT (_stream_readable.js:1184:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)

Alexa-Remote always returns "Response: No body" and then Alexa speaks the text, but it appears that the status code is something other than 200 when the problem starts occurring. Here's how the logs look when the command is successful:
Alexa-Remote: No authentication check needed (time elapsed 24222)
Alexa-Remote: Sending Request with {"host":"pitangui.amazon.com","path":"/api/behaviors/preview","method":"POST","timeout":10000,"headers":{}} and data={"behaviorId":"PREVIEW","sequenceJson":"{"@type":"com.amazon.alexa.behaviors.model.Sequence","startNode":{"@type":"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode","operationPayload":{"deviceType":"AKNO1N0KSFN8L","deviceSerialNumber":"G0B0H506617700D3","locale":"de-DE","customerId":"AWMF3SVYOF8RS","textToSpeak":"hello"},"type":"Alexa.Speak"}}","status":"ENABLED"}
Alexa-Remote: Response: No body

As you can see, they appear to be identical except the successful attempt is receiving a status code that begins with "2".

@Apollon77
Copy link
Owner

you could add the respinse code to the Exception so that we could see what exactly the response is about. But if amazon is returning this ... could Isee your code somewhere? I personally do not experience such an effect

@sleuth255
Copy link
Author

sleuth255 commented Dec 9, 2019

yes, I've done that and am waiting for it to fail again (should be in about 15 hours).

I'm actually using your alexa-remote.js code as-is as part of a node.js web wrapper that implements the speak function. It's targeted for use as an Alexa TTS API by home automation systems such as Home Control Assistant. https://github.com/sleuth255/alexa-speaks

Your code is in the public folder. Problem occurs whether useWsMqtt is true or false. Interestingly, when the problem is occurring, your getDevices function still works fine. It is only the speech function that is failing.

@Apollon77
Copy link
Owner

Why you do not use the lib as dependency but copy the code?!
Ok ... can it be that there is a time where too many requests are send too fast and amazon rate limiting kicks in?

@sleuth255
Copy link
Author

I wouldn't think so. It fails even if I only send one command (see the logs above). I've had to work out how alexa-remote operates by looking at the code pretty much, so it was just easier to have it handy. Maybe I'm not setting everything up correctly? I'm directly using sendSequenceCommand with a "speak" function, init, and getDevices. from your code currently.

@sleuth255
Copy link
Author

sleuth255 commented Dec 10, 2019

Hmmm... its still up. The only change I made was fix a problem with the refresh cookie interval. I now have the cookie being refreshed every 12 hours. Maybe the en-US locale/site requires a more frequent cookie refresh cycle than once every 7 days? Still, this doesn't explain why getDevices was still functional but the speak function was failing. I'll keep it running and if it lasts another day, I'll close the issue.

@sleuth255
Copy link
Author

more on the bug which is that the default cookie timeout wasn't being set correctly on lines 95/96 of alexa-remote because the option name is being transposed to refreshCookieInterval.

@Apollon77
Copy link
Owner

Last bug I thought was fixed already ... maybe your code relies on an old version of Alexa cookie lib and remote lib because you hard Code all deps.

@sleuth255
Copy link
Author

shouldn't those two lines of code say this:

    if (this._options.cookieRefreshInterval === 0) {
        this._options.cookieRefreshInterval = this._options.cookieRefreshInterval || 7*24*60*60*1000; // Auto Refresh after 7 days

??

@Apollon77
Copy link
Owner

No code is correct.

If you set the Intervall to 0 then no auto refresh is done. Else it will be used it set to 7days if it has a falsy value (false, null, undefined)

@sleuth255
Copy link
Author

sleuth255 commented Dec 10, 2019

so

   if (this._options.cookieRefreshInterval !== 0) {
       this._options.cookieRefreshInterval = this._options.cookieRefreshInterval || 7*24*60*60*1000; // Auto Refresh after 7 days

is correct then. That's how I have it currently. changed from this:

    if (this._options.refreshCookieInterval !== 0) {
        this._options.refreshCookieInterval = this._options.refreshCookieInterval || 7*24*60*60*1000; // Auto Refresh after 7 days

@sleuth255
Copy link
Author

sleuth255 commented Dec 10, 2019

I'll pull your library in as a dependency. It looks like my setting it to 12x60x60x1000 coupled with the above change has allowed the server to run for more 32+ hours and counting so far.

@Apollon77
Copy link
Owner

Hm ... it is very strange that it should need refreshs that often.

@sleuth255
Copy link
Author

sleuth255 commented Dec 11, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants