MirrorMirrorOnTheWallSkill icon indicating copy to clipboard operation
MirrorMirrorOnTheWallSkill copied to clipboard

Lambda Response Service Simulator Error

Open qgoehrig opened this issue 7 years ago • 2 comments

This is a copy of an Issue I created on the MirrorMirrorOnTheWallSkill Github page.

It seems that there are a few other issues addressing this issue that don't have fixes, so I'd figure I'd post my issue with as a detailed report. The Lambda Response from the service simulator in the Skill test returns the following error.

The remote endpoint could not be called, or the response it returned was invalid.

My lambda request is as follows with a few fields omitted:

{
  "session": {
    "new": true,
    "sessionId": "MY-SESSION-ID",
    "application": {
      "applicationId": "MY-APP-ID"
    },
    "attributes": {},
    "user": {
      "userId": "MY-USER-ID"
    }
  },
  "request": {
    "type": "IntentRequest",
    "requestId": "EdwRequestId.486a3b43-cf13-46c0-a696-cfc9ba39725a",
    "intent": {
      "name": "MirrorMirrorHelloIntent",
      "slots": {}
    },
    "locale": "en-US",
    "timestamp": "2018-01-23T03:04:11Z"
  },
  "context": {
    "AudioPlayer": {
      "playerActivity": "IDLE"
    },
    "System": {
      "application": {
        "applicationId": "MY-CORRECT-APP-ID"
      },
      "user": {
        "userId": "MY-USER-ID"
      },
      "device": {
        "supportedInterfaces": {}
      }
    }
  },
  "version": "1.0"
}

Diving further into the Invocation Logs in AWS lambda (as seen through CloudWatch), I get the following error stack trace:

module initialization error: Error at new DeviceClient (/var/task/node_modules/aws-iot-device-sdk/device/index.js:445:13) at Object.DeviceClient [as device] (/var/task/node_modules/aws-iot-device-sdk/device/index.js:216:14) at Object.app.setup (/var/task/MirrorMirror.js:11:23) at Object. (/var/task/index.js:21:14) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17)

On the last bit of the exception in /node_modules/aws-iot-device-sdk/device/index.js, the error that is being throw is from

if (isUndefined(option.host)) {
    throw new Error(exceptions.INVALID_CONNECT_OPTIONS);
}

Perhaps this can offer some insight as to where I'm going wrong here.

I feel that there are many users here like myself who are still struggling to get past this point, so any help is greatly appreciated!

qgoehrig avatar Jan 23 '18 03:01 qgoehrig

There is something missing that someone else identified as being required for this to work. Prior to uploading the .zip file created in step 3 to Lambda, edit the /src/MirrorMirror.js file and add a new line under region: "us-east-1", (~line 16) and add host: "YOURID.iot.us-east-1.amazonaws.com", so the entire section looks like this:

app.setup = function() {
  app.device = awsIot.device({
    keyPath: __dirname + "/certs/MagicMirror.private.key",
    certPath: __dirname + "/certs/MagicMirror.cert.pem",
    caPath: __dirname + "/certs/root-CA.crt",
    clientId: "MirrorMirror" + (new Date().getTime()),
    region: "us-east-1",
	host: "YOURID.iot.us-east-1.amazonaws.com",
  });

You need to get your IOT endpoint created at the beginning for that line - to do that, go to AWS > IoT > Settings and copy the value under Custom Endpoint. Credit to torresfm

After making that addition, save the MirrorMirror.js file and then create your zip for upload.

XJonnyP avatar Mar 05 '18 13:03 XJonnyP

Having the same problem, the solution from @XerqJon doesn't working for me

felangga avatar Oct 31 '18 15:10 felangga