Websockets
-
@Igor-Neuhold I think the reason that
socket.io
wasn't working on the Omega is because it is dependent on some binary components that needs to be cross-compiled for the Omega. We are still working on a way to cross compilenode.js
modules, but the way it is done is very similar to cross-compiling other packages for the Omega. Do you have a cross-compile environment setup according to https://wiki.onion.io/Tutorials/Cross-Compile? If so there might be a few things that you can try.Cheers.
-
I've managed to get binary data with socket.io (i had to remove everything else just to try it out, it's not really lightweight), so there, problem solved, socket.io works and i can send and receive binary data.
I'm using browser to convert mp3 chunks to PCM and send it back to omega and would like to stream that data to speaker.
Got any idea how i can pull that off with just omega, amp and a speaker?
Guys at #arduino suggested that i can use external USB sound card but i'm still hoping for some better way.
-
@Igor-Neuhold Yeah, external USB sound card is the best way. We were thinking about building an audio expansion that communicates with the Omega via I2S, but the sound quality turned out pretty bad. So we will be releasing an audio expansion that's USB-based as well.
Would you be able to post the instructions on how to compile the
socket.io
binary? I think many people would find that extremely helpful.Thanks!
-
I have installed socket.io with npm in an empty directory (i'm on ubuntu, not sure if that plays any role in this) and just transferred node_modules directory over ftp to omega.
I think it's 4 MBs or so, quite large so not sure how useful it is to you guys. If I find a better way I'll let you know
-
@Igor-Neuhold Hmm, then that means the binary is compiled for your computer rather than for the Omega. It was able to run on the Omega without any issue?
-
2 errors show up, same like when using binaryjs or ws, but with those 2 libs sockets get disconnected immediately after connection, with socket.io i get 2 warnings that 2 modules are not ELF executable for MIPS but i've read socket.io has a bunch of fallbacks so i guess that's the reason why it works. I can even send and read binary data.
But the biggest problem is that socket.io takes up to 4.1MB
-
@Igor-Neuhold Ah, i see. Socket.io is probably falling back to long-polling to accomplish the same tasks. Can you try to removing the binary files (that's not ELF executable for MIPS) to see if that reduces the module size by any significant amount?
-
around 100kb less, not enough. I would need to figure out exactly to what socket.io falls back to and remove everything else so it has a reasonable size.
-
@Igor-Neuhold Looking at the dependency tree of
socket.io
, it seems to be dependent onws
. How big was ws when you were using it? Also when i look at the dependencies ofws
, it's dependent onoptions
andultron
, both are 100% native node applications, so i'm not quite sure which package is dependent on theutf-8-validate
module that was giving the error.
-
just ws are ~800kb
bufferutil and utf-8-validate throws as not ELF exec...
and ws disconnects user after it receives connected event, i'm guessing that socket.io fallsback to something else?
-
@Igor-Neuhold Yeah, i think it should be the
socket.io
that's falling back to long polling. It seems like you will need to change some code to tellsocket.io
to start directly with long polling instead of tryingws
first. This way you will be able to removews
entirely and save 800kb of space.
-
it would be better to avoid socket.io and use ws compiled for MIPS, i just have no idea how to do that. Just saying if we had working ws and have an option to avoid socket.io we would save 3.2MB
-
@Igor-Neuhold Can you isolate the source code for
bufferutil
andutf-8-validate
?
-
you mean in ws?
I'm not sure that's the way to go. Can't you just compile ws for MIPS or something?
as for storage I guess 4mb ain't so bad with some external data device
-
@Igor-Neuhold
ws
is compiled bynpm
, but in order to cross-compile them for the Omega we will need to get the source code and use the cross-compile toolchain to compile them (because we don't havenpm-gyp
on the Omega).
-
maybe this can help: http://fibasile.github.io/new-node-modules.html
-
@Igor-Neuhold Thanks for sharing! I will test them out
-
I'm looking forward to seeing
ws
working with Node.js on Onion
-
@Sergiy-Kyrylkov Do the packages listed here work? http://fibasile.github.io/new-node-modules.html
-
@Boken-Lin I don't know. We cancelled our Onion orders until Node.js is confirmed to work with the libraries we need (Mongoose, ws). Also Node.js 0.10 has a regression which breaks our code on Intel Edison, so we cannot use anything less then 0.12