• I am trying to follow this example to setup a sample Websocket Client but the client won't connect nor does it thrown an error. None of the callback functions are ever called.

    I made sure that the WiFi is connected before the Websocket is initialized. The server doesn't see that the client running on Espruino on an ESP8266 is even connected. Does the built-in Websocket support the built in @require("Wifi") model?

    This same code runs fine when run from the Mac console when the websocket client is running inside the Mac and the server is also on the Mac.

    I have verified that the HTTP object is able to call another Web-server on the Mac.. So its definitely not a connectivity issue.

    Just need to know if the WebSocket object knows to utilize the connection as established by the Wifi.connect() API.

      var host = "ws://192.168.1.101:8080";
      var ws = new WebSocket(host);
    
      ws.on('open', function() {
        console.log("Connected to server");
        setTimeout(saySomething, 5000);
      });
    
      ws.on('message', function(msg) {
        console.log("MSG: " + msg);
        setTimeout(saySomething, 5000);
    
      });
    
      ws.on('close', function() {
        console.log("Connection closed");
      });
    
      ws.on('handshake', function() {
        console.log("Handshake Success");
      });
    
      ws.on('ping', function() {
        console.log("Got a ping");
      });
    
      ws.on('pong', function() {
        console.log("Got a pong");
      });
    
      ws.on('rawData', function(msg) {
        console.log("RAW: " + msg);
      });
    
      function saySomething() {
        ws.send("{'test':'123'}");
      }
    
About

Avatar for swaroop @swaroop started