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.

domguinard (71) [Avatar] Offline
Moving question from:

I tried pattern 3 in chapter 7, cloud gateway but the code not work. Although I have run the file but server just hanging and not updating thng properties. I tried to build my own with local mqtt server but It cant be accessed by web browser. Could you give me some clue how to build something like evrythng? How to build a server resolving both mqtt and http request?
domguinard (71) [Avatar] Offline

We just tested the code again and it does work for us.

Did you register with EVRYTHNG first? Did the script populate the objects (Thngs, etc.) in your EVRYTHNG account?
Do you use Linux or Windows?

Once the script has run you need to run:
 node simple-plug.js 

to actually start the example.
431450 (10) [Avatar] Offline
Hi Dom,
Really sorry for posting unrelated question in another thread.
I'm using Ubuntu 16.10. I have registered an EVRYTHNG account and got a operator API key.
Then in terminal when I run [ $ sh XXX ], I've got an error " 9: Syntax error: "(" unexpected".
I tried again with [ $ ./ XXX ], It does steps 1-4 and also create action and redirect Url for me, and I also checked, project, product, thng has been created in my ERVYTHNG account and 5 times updated by But when I run
[ $ npm install ] //success
[ $ node simple-plug.js ]
The terminal just log with "Using Thng #YYY with API Key: XXX" and not updating my thng properties.
Thanks for replying soon.
domguinard (71) [Avatar] Offline
Very good catch, thanks for that. I managed to reproduce your issue (on a Linux box only, not on a Mac), looking into this now. I submitted it as a bug on github if you want to track the progress:
domguinard (71) [Avatar] Offline
Okay, we managed to fix it:

Basically the issue was that on MacOS the sh is actually bash while on Ubuntu it points to dash

So when you were running the script with
on your machine it was running it with dash which does not support the same language set, hence the error.

You can now pull master:
git pull origin master
and you should get the fix. Then run
sh XXX

Essentially the fix forces using bash if it's not using it.

Thanks a lot for reporting this bug, this was a really good catch!
431450 (10) [Avatar] Offline
Hi Dom,
Thanks for fix bug sh, but the problem is still there, when I run
[ npm install ] //success
[ node simple-plug.js ]
It's not updating my thng prop. It just hangs the terminal with the line "Using Thng #XXX with API Key: YYY.
I include my output in a file.
Hoping for replying soon. ( I have trouble with this book forum when replying thread because the language display is French I guest )
domguinard (71) [Avatar] Offline
Hi there,

I think what's happening is a side effect from the bug that you had with the .sh file: some resources were created but the _setStatus action is not scoped correctly (i.e., is not part of the project the app uses) as the call failed.

I fixed this in you account directly and it should now work. An alternative would have been to go to ActionTypes in the EVRYTHNG dashboard ( while ensuring that no project was selected (Current Project: None). Then, select the _setStatus Action and move it to the corresponding Project (Web of Things Book).

But again, I fixed that for you so it should now work, try it again.

Thanks for the report and sorry for the inconvenience.
431450 (10) [Avatar] Offline
Hi Dom,
I deleted all existing projects and created a new one by [sh XXX] command.
It all successed except {"status":404,"errors":["Custom action type _setStatus not found."]. Then I added __setStatus action type that you created in this new project, run [node simple-plug.js] and still, nothing happen. Thng can be updated by http request curl POST but cant be updated by sending mqtt request.

I think the problem is establishing connection to server because I'm running simple-plug.js file, not plug-with-control, so there nothing relate to __setStatus. I tried to connect to but it failed too. May be the connection is abandoned by my company network. I will give it a try at home.
domguinard (71) [Avatar] Offline
Now, you are onto something really interesting here!

We had this types of issues with corporate firewalls while deploying projects at EVRYTHNG's customers. As a fallback the EVRYTHNG pub/sub component also supports ports 443 (secure) and 80 (unsecure) which should hopefully be open if you get access to the Web!

Try changing line 11 from simple-plug.js from:

var client = mqtt.connect("mqtts://", {// #B


var client = mqtt.connect("mqtts://", {// #B

this should hopefully let you through. Let us know!
431450 (10) [Avatar] Offline
Hi Dom,
It worked.
Thank you very much.
Now I will continue reading your book. I left it when I could not run this example.