rgraciano / echo-sonos

Amazon Echo integration with Sonos
Other
712 stars 235 forks source link

"Unexpected token" error with SQS proxy #177

Closed elmedico27 closed 7 years ago

elmedico27 commented 7 years ago

I'm using the SQS proxy and getting an "unexpected token" error invoking anything. It appears as though nothing is getting through the proxy (both running on the same server in PM2 process manager).

The lambda function itself tests out okay with the presets test file:

{ "version": "1.0", "response": { "outputSpeech": { "type": "PlainText", "text": "OK" }, "shouldEndSession": true }, "sessionAttributes": {} }

but I get an error in the log output:

START RequestId: 43ec0834-499b-11e7-9821-6fdd89621437 Version: $LATEST 2017-06-05T03:01:26.668Z 43ec0834-499b-11e7-9821-6fdd89621437 session applicationId: MYAPPID 2017-06-05T03:01:26.668Z 43ec0834-499b-11e7-9821-6fdd89621437 dispatch intent = PlayPresetIntent 2017-06-05T03:01:26.668Z 43ec0834-499b-11e7-9821-6fdd89621437 PlayPresetIntent received 2017-06-05T03:01:26.668Z 43ec0834-499b-11e7-9821-6fdd89621437 Sending SQS '/preset/test' 2017-06-05T03:01:26.828Z 43ec0834-499b-11e7-9821-6fdd89621437 SQS purged queue 2017-06-05T03:01:26.953Z 43ec0834-499b-11e7-9821-6fdd89621437 SQS successfully sent message /preset/test 2017-06-05T03:01:47.027Z 43ec0834-499b-11e7-9821-6fdd89621437 SQS successfully received response 2017-06-05T03:01:47.028Z 43ec0834-499b-11e7-9821-6fdd89621437 SQS '/preset/test' failed 2017-06-05T03:01:47.028Z 43ec0834-499b-11e7-9821-6fdd89621437 [TypeError: Cannot read property '0' of undefined] END RequestId: 43ec0834-499b-11e7-9821-6fdd89621437 REPORT RequestId: 43ec0834-499b-11e7-9821-6fdd89621437 Duration: 20373.74 ms Billed Duration: 20400 ms Memory Size: 128 MB Max Memory Used: 43 MB

and if I test any utterance from the Alexa skills dashboard, I get the following:

"version": "1.0", "response": { "outputSpeech": { "type": "PlainText", "text": "The Lambda service encountered an error: Unexpected token T" }, "shouldEndSession": true }, "sessionAttributes": {}

I've tried using both root account keys and a separate user and neither seem to work. My user account credentials aren't even getting hit -- when I look at IAM for the security credentials of my user (the keys of which are in settings.json) I see that the last use is "N/A". I'm also using the default options.js with environment variable declarations in lambda vs. updating options.js directly.

elmedico27 commented 7 years ago

Update: not any utterance. I tested the play and pause intents, and those work fine. Seems to be just on music searches (my default service is library).

elmedico27 commented 7 years ago

Found my issue -- my echo-sqs-proxy was erroring out because it didn't have async installed. Didn't realize it at first because I was running the script in PM2, which I eventually noticed had a high number of restarts. Ran it on the command line with npm start and saw the error right away. As soon as I installed async, all of my SQS messages from my tests came pouring through.

I submitted pull request #178 which adds async as a dependency for echo-sqs-proxy.