I have nodejs installed and i'm using binaryjs to send and receive binary data, i've tested my code on ubuntu, same node version and everything else, but for some reason websocket connection on omega breaks as soon as i connect, I have changed keep alive from 120 to 7200 but it didn't help, i'm running out of ideas.
I think it's OS issue or something, can someone point me to the right direction or suggest what to do next? I've lost my mind, googling for hours..
alright, made some progress, so i was using binaryjs, now i've tried "ws" and got output errors which led me here:
but still one file is giving me:
'node_modules/utf-8-validate/build/Release/validation.node' is not an ELF executable for MIPS'
Does anyone know some easy way to compile node modules for MIPS?
@Igor-Neuhold I think the reason that
socket.iowasn'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 compile
node.jsmodules, 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.
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.iobinary? I think many people would find that extremely helpful.
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 on
ws. How big was ws when you were using it? Also when i look at the dependencies of
ws, it's dependent on
ultron, both are 100% native node applications, so i'm not quite sure which package is dependent on the
utf-8-validatemodule 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.iothat's falling back to long polling. It seems like you will need to change some code to tell
socket.ioto start directly with long polling instead of trying
wsfirst. This way you will be able to remove
wsentirely and save 800kb of space.
@Igor-Neuhold Can you isolate the source code for
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
wsis compiled by
npm, 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 have
npm-gypon 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
wsworking with Node.js on Onion