• Thanks Gordon,

    I've created another WiFi network with an Apple Airport hub and everything is fine now. There is definitely something 'in' my BT hub that is stopping the connections. I'll have a poke about.

    WebSockets is not working as expected at the moment. I'm wanting to create a server on the Expruino and then connect to it from a client running in Chrome.

    On the Chrome side I connect like this:

    	var socket = new WebSocket("ws://"+matrixip);
    	socket.onopen = function(event) {
      		console.log("Connected to WebSocket");
    	};
    	socket.onerror = function(e) {
    	  console.log('WebSocket Error: '+e);
    	};
    

    And later on simply:

    socket.send("Hello World!");
    

    And on the Espruino:

    function onInit() {
      neopixel = require("neopixel");
      neopixel.write(MATRIXPIN,[255,0,0]); // On
      wifi = require("EspruinoWiFi");
      wifi.connect(WIFI_NAME, WIFI_OPTIONS, function(e) { 
        if (e) {
          console.log("Connection Error: "+e);
          neopixel.write(MATRIXPIN,[0,255,0]); // Connection Error
          return;
        }
        wifi.getIP(function(f,ip) {
          info.macaddress = ip.mac;
          info.ipaddress = ip.ip;
          console.log("Connected: ",info);
          var server = require("ws").createServer(processReques­t);
          server.listen(80);
          server.on("websocket", function(ws) {
            console.log("Connection upgraded");
            ws.on('message',function(msg) {
              console.log("Message received");
              print("[WS] "+JSON.stringify(msg));
            });
            ws.send("Hello from Espruino!");
          });
          neopixel.write(MATRIXPIN,[0,0,255]); // Connected
        });
      });
    }
    

    But the connection never completes from Chrome with this error:

    'ws://192.168.1.111/' failed: Error during WebSocket handshake: Response must not include 'Sec-WebSocket-Protocol' header if not present in request: undefined
    

    Any thoughts?

    Sean

About

Avatar for seanclark @seanclark started