Local pi server running node and websockets - node.js

I'm just wondering is it possible to run a local server using node (node would be running on a raspberry pi) and communicate with it via a web browser on a different machine on the same network using websockets? I'm looking into using a browser as a control system for a project I'm working on. If it is possible is there any references I can look at?
Thank you,
Techhead55.
EDIT
I already have node up and running on the pi, it's just that I'm not sure if you can and how you implement a local server and use sockets to communicate with it in a bowser on the same network.

Not sure if you specifically ask about Node, but here is an example of a WebSocket server running on Pi, and browsers connecting to that server: http://tavendo.com/blog/post/pypy-on-the-pi/
The example does Publish & Subscribe over WebSocket using WAMP (http://wamp.ws).
Here is a similar example running on Arduino Yun that shows how to connected hardware, and publish data in real-time via WebSocket, receiving data in a browser, and real-time rendering a chart: http://tavendo.com/blog/post/arduino-yun-with-autobahn/
Disclosure: I am original author of Autobahn and work for Tavendo.

Yes.
Here is great manual from Matthias Rüedlinger:
http://blog.rueedlinger.ch/2013/03/raspberry-pi-and-nodejs-basic-setup/
Also installation of ghost with node on RPI is very nice :)
http://bit.ly/1cFwFAQ

Related

Control a mac with nodejs server

I do not really know where to post this question.. I have a nodejs server running on my mac. It listen for message if it receives "shutdown" then I run a command which turns off the mac. This works really great locally in my network. Now how to do the same but outside my local network. Lets say that I want to turn of my computer outside my house always using my nodejs script? Using dns setup? Thanks in advance!

CGI version of expressjs

I want to create a small web service and for that I really want to use node.js and express.
I already have an Apache running on my little server (it's a Raspberry PI :P ) which receives all the traffic. How can I configure a VirtualHost to be served by node.js?
I searched a lot and I found many solutions, namely:
Use ProxyPass to forward requests from Apache to node.js
Use Rewrite rules in .htaccess file
Use VPS
But all these solutions require a running daemon for node.js and resources are scarce on Raspberry PI (it only has 256MB of RAM). So I searched a bit more and I found this solution:
GGI-Node provides the ability to run JavaScript on any web server just like PHP as a CGI using Node.js.
But again, this solution doesn't fulfill my requirements. GGI-Node is more of an adaptation of node.js to PHP and it's not possible to use with/like express.
So I came up with an idea: what about modifying express to keep the same behavior and functionality and, instead of creating a server, feeding express with info from Apache via CGI? I searched even more and I didn't find anything like that... Is this possible to do? How hard would it be to implement?
I know this solution doesn't take the advantages of node.js asynchronous I/O, but it's not important in my case.
Here's one possible solution: Get another Raspberry Pi or two :-)
No, I'm not kidding. Here's what I'm thinking:
With one additional Raspberry Pi:
Set up the Raspberry Pi running Apache as a proxy for your new virtual host & route all the traffic for that virtual host to Raspberry Pi #2. Set up node.js and your express application on Raspberry Pi #2.
With two more Raspberry Pis:
Leave Raspberry Pi #1 as is (with Apache & whatever other web site you have running on it).
Set up Raspberry Pi #2 with node.js & your express application
Setup up Raspberry Pi #3 with a proxy and proxy requests to #1 & #2. Apache can do it, although it's a pretty "heavy" solution - I'd go with nginx personally.
Actually, you could do it with just one Pi
Set up the Express app to listen on some arbitrary port & use Apache to proxy requests to the new virtual host to that port.
However...
How ever you do this, be advised that the Raspberry Pi (at least the earlier models) are not good at running node.js. I tried this (running an Express app) with an original Raspberry Pi and performance was not good (I wound up rewriting the code in go). You might have better luck with a Pi 2 or a Pi 3.
If you decide to go this route...
Here's a link to a Digital Ocean tutorial on using Apache as a proxy. I haven't followed this tutorial, so I can't vouch for it, but a cursory glance suggests that it's pretty complete.

How can I test a OPC-UA server running on Raspberry Pi from a Windows computer?

As a part of a job assignment where I am to implement and test an OPC server on a Raspberry Pi, I found and implemented a node.js server found at this Github repository (sample_server.js).
Now, being new to OPC in general, I tried downloading the MatrikonOPC Explorer to connect to the server, but it refused to find the server. At first I thought I was just not putting in the right things (endpoint URL goes somewhere?) into the connect prompt, but having read some more, (I think) I now understand that the explorer uses the regular OPC specification while my server is a OPC-UA server. Please correct me if I'm wrong here.
Anyway, I would like to see if this server actually works and can be accessed. What is a good way of testing this? If possible, I would like to test it over the network, from my Windows PC (they are both on the same network, and I have ensured they are pingable from eachother).
It turns out my suspicion was right - the problem was solved by adding a UA proxy that translated the OPC-UA to OPC Classic, allowing the explorer to detect and access the server.

AR Drone over the internet

I have an ar drone that i want to fly via the browser. It currently works on localhost but as the live server is not using my machine, the drone doesn't react to the commands.
How do I get the drone to fly while connected from my machine but controlled over the internet?
I'm not worried about latency as i only need it to take off and land.
I have a signalR project about ArDrone it's control drone over internet and it works. I can send you codes
#Chris you might want to check the NVextender at http://developers.NVdrones.com. There will be a Javascript SDK that you can run in Node that maybe will allow you to achieve what you are looking for.

nodejs and websockets on Windows

I looked through a number of posts on websockets, nodejs, and socket.io and could not find an answer to this question.
I would like to set up a development environment using nodejs to develop websockets application. I would prefer to run Windows since I have physical hardware running Windows and I am very comfortable with VS, but I could set up a Linux box running nginx or apache if necessary. I have explored iisnode, which has good support for node.js, but has no support for websockets since IIS 7.* does not support websockets. I also know Windows 8 supports websockets, but I need Server 2008 R2 and Windows 7 for other tasks, so I would like to avoid that until it is released.
What has worked well for other developers of websockets using nodejs with or without windows as a server development environment?
I am using NodeJS with WAMP (win x64 php 5.x, apache 2.2.x, mysql 5.x) and I'm pretty happy with it, besides a few problem keeping up a long time socket connection between a browser and NodeJS (socket.io). As it's a socket server on its own (with socket.io), i don't have any hooks with apache ! It's pure javascript. And if i need to interact with apache/php/mysql, i just do some posts requests... Also there are modules to interact with mysql.

Resources