Node.js and socket.io on the yun

Hi!
I'm wondering if anyone uses socket.io module for node.js, if it has sense or it is too much for the linino

I have used socket.io with node.js, works well.

Haven't tried it with the Yun yet, but can't see it will present any problems.

socket.io on the yun cannot be installed at the moment, since it requires a native module (ws). It's the oven. It should be available later next week

what can I say? wow!
so.. I'll wait till the end of the next week.
Just three more question:

  1. where can I follow the development?
    openwrt-yun/package at master · arduino/openwrt-yun · GitHub
    I don't see the node package (even if I installed it by the opkg node install with the new openwrt-ar71xx-generic-yun-16M-squashfs-sysupgrade image following the cool tutorial and the arduino sketch that worked like a charm)

  2. are there more stable examples of web sockets? maybe with python.. in another post I've seen that websocket&python are used in space brew.
    The python websocket lib is the one from Hiroki Ohtani (liris).. but I didn't found examples or tutorial on that. Is there any well-tested and documented websocket lib available?

  3. just to not to lie down in the xy problem ( What is the XY problem? - Meta Stack Exchange ):
    I want a web page be notified without refreshing it when something is happening in the board (i.e. a pushbutton is pressed).
    As far as I have understood I have to open a double way communication between the server and the client, if I don't want a continuous polling (like the yun-examples/analogInputs at master · mat-lo/yun-examples · GitHub where the js setInterval continuously ask the serve status) - and mainly I don't want to not overload the network.
    I think that socket.io with node.js could be a nice option.
    Is there something obvious that I'm not aware of?

Sorry if this is a dumb question, I'm new to this internet-of-things stuff.

..for the node.js look at fibasile's work:
http://fibasile.github.io/compiling-nodejs-for-arduino-yun.html
and

and also here:
http://giorgiocefaro.com/blog/installing-node-js-on-arduino-yun

and here:

..nodejs is not the problem. the problem is socket.io.
what I have already done: upgrade at the last image, expand with an external sd card for the boot and install node.js via npm install node. everything works like a charm.

node.js is working, but try to install socket.io via npm install socket.io fails (after more then 10 minutes ssh session crashes and require('socket.io') from node console gets some errors like "Error: Cannot find module 'zeparser'", same for require('ws')).
but Federico answer explains why :slight_smile:

anyway! I was not aware of ws module compiled for websocket in fbasile repository, I'll try it out, thanks!

Packages repo is GitHub - arduino/openwrt-packages-yun

python has a websocket library, spacebrew uses it

Your server side node code will still need to poll the Bridge to see if and what changed (and we haven't a node bridge library yet, contributions are welcome!). Then your socket.io would emit a message and your browser will react accordingly

just a feedback:
with the fibasile compiled ws module and then npm install socket.io everything seems to work fine

In the meanwhile we just released a couple of native node modules: socket.io, socket.io client, noble, bleno, ws

super good! thanks!

i just installed node.js as well as the new node-js package on my yun, but ran into a problem when connecting to a websocket-server on a remote host.... using small client.js and server.js programs which i've run on a wide-range of systems (PC, OS/X, Linux), i catch an on('error', ...) event that informs me that my serverKey and expectedServerKey do not match....

if i run this test using 'ws:localhost:8080', everything works; but when i use a remote host, i receive this error.... again, the same code works just fine across a variety of other hosts....

looking at the code in WebSocket.js, 'expectedServerKey' is a SHA hash of something sent in the original websocket request; the server response is supposed to match this.... needless to say, this works on the same localhost....

i have seen comments that there might be issue with hash computations???

is there any other package i should install on my yun???

thanks... bob.

biosbob, I see you've already comment on the blog. Indeed I too think that's the issue. For the record, after that comment, I've upgraded v8 to the same version used by debian, 3.14.5, but that didn't solve the issue
I'll look into it asap. If you can google for some suggestions, you're welcome to contribute

You can install a precompiled version of socket.io:

opkg update
opkg install node-socket.io

Check out my project on github where I use the serial port and websockets to display incoming audio on a graph: GitHub - imec-int/arduinoyun-sounddetector: Building an internet connected Sound Detector on an Arduino Yun using Node.js

SamDecrock:
You can install a precompiled version of socket.io:

opkg update

opkg install node-socket.io




Check out my project on github where I use the serial port and websockets to display incoming audio on a graph: https://github.com/mixbe/arduinoyun-sounddetector

Thanks for that codebase, it was very valuable in chasing a bug I had. Mainly due to the fact that I was still using 0.9.x socket.io code parts here and there but I wasn't aware of that yet. Cheers!