• user88627

    I am using NodeMcu with espruino_1v96 .

    I write a program in debugging mode its working fine . when same program write in NodeMcu using save();
    program is not working .

    here is my Code

    var led = new Pin(D4);
    var host = "";
    var WebSocket = require("ws");

    var ws = new WebSocket(host,{
    path: '/',
    port: 8000, // default is 80
    protocol : "echo-protocol", // websocket protocol name (default is none)
    protocolVersion: 13, // websocket protocol version, default is 13
    origin: 'Espruino',
    keepAlive: 60,
    headers:{ some:'header', 'ultimate-question':42 } // websocket headers to be used e.g. for auth (default is none)
    ws.on('open', function() {
    console.log("Connected to server");

    ws.on('message', function(msg) {
    var data = JSON.parse(msg);
    digitalWrite(led, data.bulb?1:0);


  • Check out http://www.espruino.com/Saving

    you need to put your code in an onInit function (or ideally actually wait until you know WiFi is connected with http://www.espruino.com/Reference#l_Wifi­_connected).

  • Thanks i use onInt with settimeout now its working

  • @user88627, using a setTimeout() to wait for Wifi to become connected is a cludge tower... It will come crashing down sooner or later, that's no question... use callback technique instead...

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

WebSocket not work after code burn into NodeMcu using espruino IDE

Posted by Avatar for Saurabh @Saurabh