LowPowerLab Forum

Software support => Pi Gateway => Topic started by: Memnon on July 03, 2014, 01:19:20 PM

Title: Raspberry Pi Gateway Setup (nginx, nodejs, socket.io)
Post by: Memnon on July 03, 2014, 01:19:20 PM
Hi

I just got my Raspberry Pi, and im trying to get the gateway setup. But i dont get any loonger than the nginx install.

This command is ok
sudo chmod +x /etc/init.d/nginx

But this line I get an error
sudo update-rc.d -f nginx defaults
I followed the guide to every line. and no errors before this.

this is the error i get:
update-rc.d: using dependency based boot sequencing
insserv: warning: current stop runlevel(s) (empty) of script `nginx' overrides LSB defaults (0 1 6).


Any idea on how to get past this?

Many thanks
Title: Re: Raspberry Pi Gateway Setup
Post by: Felix on July 03, 2014, 02:17:05 PM
Memnon,
Sorry but I don't know what that means. I PM-ed you a link to a good known image of raspberryPi, check your personal messages.
Title: Re: Raspberry Pi Gateway Setup
Post by: charlieroot on November 01, 2014, 08:17:02 PM
I just started the Pi gateway setup today. All seems to go well but I run into this error...

pi@raspberrypi ~/moteino $ node gateway.js &
[1] 8270
pi@raspberrypi ~/moteino $
/home/pi/moteino/gateway.js:8
io.configure(function () {
   ^
TypeError: Object #<Server> has no method 'configure'
    at Object.<anonymous> (/home/pi/moteino/gateway.js:8:4)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

I've commented out the offending parts and it'll start now. My browser only shows "Loading socket ..." and an empty box below where I can type into.


Thanks
Title: Re: Raspberry Pi Gateway Setup
Post by: Felix on November 06, 2014, 07:44:53 AM
Hard to tell. It's probably some mismatch version between the modules or something you might have missed, a setting or path. Don't give up.
Title: Re: Raspberry Pi Gateway Setup
Post by: charlieroot on November 10, 2014, 01:36:24 AM

I managed to get it working!

My problem lied in /var/www/default/index.php and this line...

old version
<script src="socket.io.js"></script>

new version
<script src="/socket.io/socket.io.js"></script>

Can't believe this got me stuck for a week.

Time to get this baby wired up and give it a spin!


Title: Re: Raspberry Pi Gateway Setup
Post by: Felix on November 10, 2014, 08:47:56 AM
Glad you found the culprit, a small thing like that can really mess you up and it can be so frustrating ... been there done that, MANY times :)
Title: Re: Raspberry Pi Gateway Setup
Post by: charlieroot on November 16, 2014, 06:33:00 PM
I actually have another question on this now that mine is working.

If I open up a new web browser and hit the pie, it's unable to get the current status, it just says it's getting the status and never does. If I change the state of my magnets, both my new web session and my old one will update correctly.

Is this by design or do I have something else wrong?
Title: Re: Raspberry Pi Gateway Setup
Post by: Felix on November 16, 2014, 07:39:10 PM
No, it should update. Basically it tells the gateway to ask the node what the status is. The node should reply and everything should just fall through and update on the client.
Title: Re: Raspberry Pi Gateway Setup
Post by: nathanaelb on November 25, 2014, 04:24:35 PM
Hello,
I'm experiencing the same proble than charlieroot & Big Country, executing "sudo node chat.js" : <<TypeError: Object #<Server> has no method 'configure'>>

charlieroot, it seems that you managed to get around this ? Could you please explain better how you did it ? I tried to comment out the problematic lines, but they are many ! I have to comment the block of lines 9-18. Now when I run node chat.js, I don't have errors, but when I browse the page "MYADDRESS/chat.html", I only get the text "USERS" and an input field with the send button, but nothing works.

I tried to change the line <script src="socket.io.js"> with <script src="/socket.io/socket.io.js"> as you said in a following post. I got a popup in my browser asking "What's your name ?", but nothing did work either.

Felix, you suggested this could be linked to the suppression of the configure method in this version of node ? In fact, I installed node and npm exactly the way proposed in the tutorial, but the version of both are LOWER than shown in the tuto :
sudo wget http://nodejs.org/dist/v0.10.12/node-v0.10.12-linux-arm-pi.tar.gz
node -v -> 0.10.0 instead of 0.10.12
npm -v -> 1.2.14 instead of 1.2.32

However, thank for the help ...
NB

Title: Re: Raspberry Pi Gateway Setup
Post by: Felix on November 25, 2014, 05:13:11 PM
I think it's a path or version mismatch somewhere ... getting the chat app to work is a useful step to understand how the node and websocket elements interact but more important is getting the gateway page and socket working which is really the point of that tutorial.
Title: Re: Raspberry Pi Gateway Setup
Post by: charlieroot on November 26, 2014, 12:08:41 AM

nathanaelb, I commented out lines 8-17 which are these....

io.configure(function () {
io.set('authorization', function (handshake, accept) {
   console.log("AUTHORIZING CONNECTION FROM " + handshake.address.address + ":" + handshake.address.port);

   if (handshake.address.address == "localhost" || handshake.address.address == "127.0.0.1")
     accept(null, true);
   else
     accept("REJECTED IDENTITY", false);
   });
});

It seems my setup can't determine the current state of the sensors, it will update when the sensors are triggered though. If we only had someone smart enough to update that code to work with socket.io 1.2.0 or higher. (I'm no coder).
Title: Re: Raspberry Pi Gateway Setup
Post by: Felix on December 16, 2014, 12:03:10 AM
This tutorial has been updated to the latest sources and distribution versions:
http://lowpowerlab.com/blog/2013/10/07/raspberrypi-home-automation-gateway-setup/
Title: Re: Raspberry Pi Gateway Setup
Post by: someotherbob on December 18, 2014, 06:01:10 PM
I have similar problems on the io.configure method missing.  The instructions on the 2013/10/07 blog post says to get the socket.io file from:  https://raw2.github.com/LowPowerLab/RaspberryPi-Gateway/master/socket.io.js

This file is missing.  So I tried the instructions at: http://socket.io/download.  I changed the /var/www/default/chat.html file to point to:  <script src="https://cdn.socket.io/socket.io-1.2.1.js"></script>

This is also throwing the error, it is saying that line 9 in chat.js can't find an io.configure function.

So I downloaded the socket.io.js file and placed it in the directory, changed the socket.io html script source back.  Still throws the error.  I changed the script source to a fully defined /var/www/default/socket.io.js.  Same error.

Am I seeing a versioning issue between what you used to host as socket.io.js and what I got from github (version 1.2.1)?

Thanks,
Not the Bob You're Looking For


Title: Re: Raspberry Pi Gateway Setup
Post by: Felix on December 18, 2014, 06:11:02 PM
Sorry if I caused confusion, I updated that blog post very recently and there is no need to get socket.io.js any more, it is downloaded from their CDN. I failed to remove that mention about the file, it's now revised. Please revisit the setup page.
Title: Re: Raspberry Pi Gateway Setup (nginx, nodejs, socket.io)
Post by: someotherbob on December 19, 2014, 03:14:51 PM
Thanks Felix.  The changes accomplished what I was fumbling around trying on my to do.

Next up is a few nodes........
Title: Re: Raspberry Pi Gateway Setup (nginx, nodejs, socket.io)
Post by: HeneryH on December 22, 2014, 02:38:37 PM
Felix, Regarding the updated blog I just captured a verbatum screencast and had a couple of very very minor comments...


I'll finish up the screen-cast and output log shortly and provide it for reference.
Title: Re: Raspberry Pi Gateway Setup (nginx, nodejs, socket.io)
Post by: Felix on December 23, 2014, 12:16:01 AM
Fixed all, but I did not verify the -y and -p commands.
Can you please check they are correct?