-
I've build the latest Espruino code base, but this time it seems taking muuuch time to upload the sketch( 10 times slower ) and then it gives me out of memory while uploading.
I've tried to copy the mqtt module inline and was able to upload it but then it gave me error wifi not defined
Uncaught ReferenceError: "wifi" is not defined at line 1 col 5 wifi.connect
-
-
-
-
Since i found that its not possible to override main WebSocket object, and since there is no way to establish simple tcp connection with html5. Another solution would be using java applet to form the tcp connection and modify its header to form a websocket client with static headers. I think this one would be possible
-
-
if the exception is related to the ws server then yes you will need to instantiate the server again, if it is not related then everything should be fine.
Question is, why would the ws server crash? this shouldn't happen unless you have an issue in the code. So i recommend you find and fix than just catch
-
-
Another idea is to do same as what i did in the client, imagine all clients sending same base64 key, in that case the server will always reply with the same accept key, you can statically define that in the header and no need for the sha1 function anymore.
And we can use custom client that always use the same key in the header, Espruino client
-
-
-
Nice work @JumJum, in my case I've used a longer Sha1 function which I couldn't include in ESP8266 because of its memory limit. So I couldnt test it actually till now.
For the keep alive all what you need is sending the ping message to the clients on interval and also pong pack if the client sent a ping.
In my ws client I found that the server was not sending me any pings and thats why I made the client keep the connections alive by sending ping requests to the server and wait for it's pong.
Is there any difference between net.createServer & http.createServer? I thought it is better to use the net one.
I will try your code when I am back home and will let you know
-
-
No, I thought I would extend the ws module and make it cover both the client and server.
So we can use it like:
/// Client var WebSocket = require("ws"); var ws = new WebSocket("HOST",{ port: 8080, protocolVersion: 13, origin: 'Espruino', keepAlive: 60 // Ping Interval in seconds. });enter code here /// Server var WebSocketServer = require("ws").Server; var wss = new WebSocketServer({port: 8080}); wss.on('connection', function(ws) { ws.on('message', function(message) { bla bla });
And thats why I wanted a way to only require the sha1 function if I am creating a server but for the client I really don't need it.
-
-
-
I have a question, lets say i have a big function called bigFunction() that is being called inside Testing module in connect() function. If I packaged this function as a module and called it something like bigFunction and instead of calling this function from my Testing module I do a require("bigFunction").
When will the require do its job and grab the file? when i require the Testing module or when I call the function that requires it?
require("Testing") <--- Will it be loaded here?
require("Testing").connect() <--- includes require("bigFunction") or only here?What I want is to only grab the big function if I required it to save space and memory
-
Thx @d0773d, I had a previous issue before with nodejs crashing and after doing lots of research for error handling etc it didn't actually work as I wanted.
Still I found this lovely piece of code that actually prevented nodejs from crashing whatever happens.
process.on('uncaughtException', function (err) { console.error(err); console.log("Node NOT Exiting..."); });
Hope it would help.
-
What would be neat is to introduce new functionality to Espruino which is Cloud controlling.
For an instance you can create new subdomain ex: cloud.espruino.com and let users register there. This will be a private cloud server for all espruino users to connect and control their modules online.You can also offer sweet dashboard to see all your nodes and statistics about them.
-
@Gordon if we are going to run the websocket server in Espruino we will loose the the main purpose of websockets which is cloud messaging. In that case you will never be able to send messages to Espruino unless you are in same network or having a static IP address.
Normally the socket server should run on a public server. Espruino & webpage or mobile app should act as a client connecting to that server as we already know it's IP. In that case you can control Espruino from anywhere.
-
@Ducky yes, actually my tests were only done on ESP8266, i didn't test it on any other board.
-
-
Guys, I've managed to write a websocket module for Espruino, you can try it out here:
http://www.espruino.com/wsPlease bare in mind it is still in an early stage, please let me know if you are facing any issues
-
@Gordon I've used to directly use the generated bins done by nkolban, Yes this was my first time to build from latest source code and flash it to my ESP