• I've manager to reproduce one of these issues using a current build on linux.

    vue native sockets in chrome browser -> Backend Espruino WS server.

    If protocol is specified, then all is well:

    const ws = new WebSocket('ws://192.168.1.203:8000', 'protocolOne');

    However, if this is defaulted, ws.js on the espruino sends as a header:

    Sec-WebSocket-Protocol: undefined

    this test seems to be failing:
    https://github.com/espruino/EspruinoDocs­/blob/master/modules/ws.js#L196-L197

    if (this.protocol)
        socketHeader.push("Sec-WebSocket-Protoco­l: "+this.protocol);
    

    in the constructor we have:
    https://github.com/espruino/EspruinoDocs­/blob/master/modules/ws.js#L76-L86
    this.protocol = options.protocol;

    So it seems this is setting this.protocol=undefined.

    What is the cleanest way to fix?

    if ( typeof(this.protocol) != 'undefined' )

About

Avatar for Wilberforce @Wilberforce started