Node.js

Last night at the GANG meeting in Southfield MI, Glenn Block talked about Node.js and some of the highlights made me wonder if Node.js would be a good candidate for a lightweight webserver on .net micro framework devices.

Right now it’s rather complicated to build a stable webserver using sockets.

So the question is, is Node.js something GHI would be interested in to add as a (proprietary?) feature? I think it could open new possibilities to build rich content webservers with javascript on embedded devices, while abstracting away the difficulties that come with building a sockets webserver from scratch.

@ Felix,

While I have no experience with other FEZ gear, and don’t know what your requirements are for a webserver on the device, I discovered last night that the ethernet module on the FEZ Spider gadgeteer board makes it super-easy to set up a simple web server and allow it to respond to requests to a given path. No sockets required.

So while node might be interesting, at least in the case of the FEZ Spider, it might not be necessary, depending on your scenario.

I only experienced with an EMX board, indeed it’s very easy to do simple web requests.
However more compliant webservers with proper header parsing, load balancing, some basic security etc, is more complicated and requires sockets and threading. I believe there are some limitations on how many connections can be open, and doing stress testing will often lock the device, but it was a while since I tried that and things might have changed.

@ Felix

We’re probably talking about different scenarios, then. I think the technique I’m talking about is best suited for simple needs.

Bear in mind that while Node is cool, it’s also rapidly changing, so might be a bit of a moving target in terms of integrating with embedded software.

Yes that’s true, simple scenarios like open TCP and listen for a known substring is fine, but if you want to do some forms and more interaction, it quickly becomes a pain.

Node is a moving target, but Microsoft is also integrating it within IIS, so that makes it that much more of a worth to look at feature, especially because it’s so modular and lightweight.

The reason I asked was because Node.js, if implemented properly in .net micro, could make it really easy to build rich intereactive and fast embedded web content without much hassle, all in javascript which is so popular. JQuery can also be used in Node.js, which would make it so cool. The real attractiveness of Node comes from the way it handles request queuing in a single thread, which I think would make so much sense on single core embedded CPUs.

I think Felix has found his next OSS project :wink:

Perhaps, but the GHI firmware is not open source (if that is what you meant), and I think I would need access to it to do the networking behind Node. Node itself would have to be integrated with the firmware with an abstraction layer on top like other features.

If I think about it more, maybe it can be done in C# with the standard microframework sockets behind the scenes.

However Node is written in C++ so it would need to be ported which could be a pain and if it’s a moving target then might not be worth porting to C#. That is why I am guessing the best route is to integrate it in the GHI firmware so it could be updated as the Node source changes.

Maybe an RLP solution would be easier then?

I tried RLP and it works nicely, but from what I remember it has limited access to the hardware peripherals, and it’s a little tricky to access even a UART. See my RLP UART debugging example to see what i mean: http://code.tinyclr.com/project/329/rlp-serial-debugging/

The GHI firmware probably is a more appropriate place to add any Node runtime.
Plus I don’t know for sure if RLP invocations can be non-blocking - as Node should run in its own thread.

I see, 1 year ago but what is with the plans to install node.js on FEZ Spider for example? That would be very great and you will have more possibilites with JS like this project: NodeCopter Brighton

Regards