GoogleCloudPlatform/iot-smart-home-cloud

Invalid configuration message SyntaxError: Unexpected end of JSON input

sw-dev-code opened this issue · 2 comments

After running sample_device.js following error occurs:

Starting Smart Home Device
connect
Config message received:
Invalid configuration message SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at MqttClient.<anonymous> (d:\Projects\Projects\Upwork\Kimberly Hachaso\iot-smart-home-cloud-master\sample-device\sample_device.js:164:29)
    at MqttClient.emit (events.js:311:20)
    at MqttClient._handlePublish (d:\Projects\Projects\Upwork\Kimberly Hachaso\iot-smart-home-cloud-master\sample-device\node_modules\mqtt\lib\client.js:975:12)
    at MqttClient._handlePacket (d:\Projects\Projects\Upwork\Kimberly Hachaso\iot-smart-home-cloud-master\sample-device\node_modules\mqtt\lib\client.js:336:12)
    at work (d:\Projects\Projects\Upwork\Kimberly Hachaso\iot-smart-home-cloud-master\sample-device\node_modules\mqtt\lib\client.js:292:12)
    at Writable.writable._write (d:\Projects\Projects\Upwork\Kimberly Hachaso\iot-smart-home-cloud-master\sample-device\node_modules\mqtt\lib\client.js:302:5)
    at doWrite (d:\Projects\Projects\Upwork\Kimberly Hachaso\iot-smart-home-cloud-master\sample-device\node_modules\readable-stream\lib\_stream_writable.js:428:64)
    at writeOrBuffer (d:\Projects\Projects\Upwork\Kimberly Hachaso\iot-smart-home-cloud-master\sample-device\node_modules\readable-stream\lib\_stream_writable.js:417:5)
    at Writable.write (d:\Projects\Projects\Upwork\Kimberly Hachaso\iot-smart-home-cloud-master\sample-device\node_modules\readable-stream\lib\_stream_writable.js:334:11)

For everyone with this issue: I was able to solve this by setting configuration message {"on": true} in IoT Core.
For developers of this page: please add this part in instructions.

Thanks for your feedback. The flow of this example is for a device to be provisioned first using the mobile client, which registers it's identity in the cloud service and sets the initial configuration with IoT Core. Will look to make this process more clear in the README.

You might also find the blog post series about the sample helpful: Part 1 and Part 2.