The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

438536 (7) [Avatar] Offline
Can I enquire in section 7.4.2 Create your MQTT client application, when I execute node simple-plug.js, I encountered the script error below. Any advice? Thanks.
root@raspberrypi:/home/pi/wot-book/chapter7-implementation/part3-cloud# node simple-plug.js
throw err;

SyntaxError: /home/pi/wot-book/chapter7-implementation/part3-cloud/config.json: Unexpected token :
at Object.parse (native)
at Object.Module._extensions..json (module.js:424:27)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/pi/wot-book/chapter7-implementation/part3-cloud/simple-plug.js:3:14)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
Vlad Trifa (16) [Avatar] Offline

It's not obvious what is happening from the terminal output, could you give us a bit more information about the issue? Version of node.js you are using, what OS, etc. Are these files straight out of git or did you change anything?

Edit: it seems there's an issue with the config.json file, can you please post its contents here (obviously obfuscating your own IDs & especially API Keys)?

438536 (7) [Avatar] Offline
Hi Vlad,

Thanks for your reply. Sorry, for not enough information before. I had repeated tried a lots of time, therefore I make a fresh start on git clone github again. Below are more info
- Hardware used: raspberry pi 3
- OS version
root@raspberrypi:/home/pi# cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION="9 (stretch)"

-root@raspberrypi:/home/pi# node -v

- I execute sh xxx where xxx is my operator API key
- i type npm install
- Then type node simple-plug.js
- My config.json is as below

I will re-generate my operator API and generate sh xxx again after you provide some recommendation to solve the error. Appreciate your help and advice. Thanks.
Vlad Trifa (16) [Avatar] Offline

ah, the following line is not valid JSON content (cannot explain why though):


Remove the -- "socialNetworks":, -- and you should be fine with the line like this:


Let us know if that works.

438536 (7) [Avatar] Offline
Hi Vlad,

It works. Appreciate and thanks for the help!