You are reading a single comment by @J{a}SON and its replies. Click here to read the full conversation.
  • when attempting to follow the websocket client example at http://www.espruino.com/ws, i get errors on the server (running node.js on a windows10 laptop) as:

    RangeError: Invalid WebSocket frame: RSV1 must be clear

    When I modify the code to use the npm ws client on the laptop, it works fine.

    server:
    node 8.9.4,
    "dependencies": {

    "express": "^4.16.3",
    "http": "0.0.0",
    "url": "^0.11.0",
    "ws": "^5.1.1"
    

    }

    espruino wifi client:
    1v97

    function wsConnect() {
        ws = new WebSocket(host, {path: '/', perMessageDeflate: false, port: 8080});
        ws.on('open', function() {
          // For WebSocket clients only
          console.log("Connected to server");
        });
    
        ws.on('message', function(msg) {
          console.log("MSG: " + msg);
        });
    
        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);
        });
    }
    
    

    output on the repl is

    wsConnect()
    =undefined
    RAW: HTTP/1.1 101 Switching Protocols
    Upgrade: websocket
    Connection: Upgrade
    Sec-WebSocket-Accept: j5MohIRvl3Pm9AVPI+aTUTQIKxI=
    Handshake Success
    Connected to server
    RAW: something
    MSG: something
    RAW: something
    MSG: something
    Connection closed
    Connection closed

About

Avatar for J{a}SON @J{a}SON started