Raspberry Pi Gateway Setup (nginx, nodejs, socket.io)

Started by Memnon, July 03, 2014, 01:19:20 PM

Memnon

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

Felix

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.

charlieroot

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

Felix

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.

charlieroot


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!



Felix

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 :)

charlieroot

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?

Felix

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.

nathanaelb

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


Felix

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.

charlieroot


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).

Felix


someotherbob

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



Felix

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.

someotherbob

Thanks Felix.  The changes accomplished what I was fumbling around trying on my to do.

Next up is a few nodes........