You are reading a single comment by @Injecteer and its replies. Click here to read the full conversation.
  • Using the following code in Espruino Web IDE:

    var WebSocket = require("ws");
    var ws = new WebSocket( 'mydomain.com', { port:8822 } );
    
    ws.on('open', function() {
      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('rawData', function(msg) {
      console.log("RAW: " + msg);
    });
    
    ws.send( JSON.stringify( { text:'HHHHLLLLL' } ) );
    

    I can see in the server logs, that the WS-connection is established and then closes within some milisecs:

    12:24:06.009 [vert.x-eventloop-thread-0] INFO com.my.GatewayWSVerticle - registered WS for [11.111.111.111]
    12:24:06.220 [vert.x-eventloop-thread-0] INFO com.my.GatewayWSVerticle - unregistered WS for [11.111.111.111]
    
    

    If I enter ws.initializeConnection(); in the left-hand side of IDE, I'm getting the lines:

    RAW: HTTP/1.1 101 Switching Protocols
    Upgrade: websocket
    Connection: Upgrade
    Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
    Handshake Success
    Connection closed
    

    If I connect to the very same server from my browser or from a z-way server @ raspi, then it works like charm.

    Am I missing something or is it a WS-bug?

    TIA

About

Avatar for Injecteer @Injecteer started