websocket server won't send

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
heing
Posts: 1
Joined: 29 Oct 2017 22:30

websocket server won't send

Post by heing »

I created a module using code from the following example from the Z-Way Manual but I cannot get the server to send data to clients. The client connects and the server prints the debug messages, but the sock.send('pong') line does nothing. I tried a couple of clients including wscat.

Code: Select all

  var sock = new sockets.websocket(9009);
  sock.onconnect = function () {
    debugPrint("client connected, sending ping");
  }

  sock.onmessage = function(ev) {
    debugPrint('recv', ev.data);
    sock.send('pong');
  }

  sock.onclose = function() {
    if (this === sock) {
      debugPrint('server websocket closed');
    } else {
      debugPrint('client disconnected');
    }
  }
  sock.onerror = function(ev) {
    debugPrint('error', ev.data);
  }
Post Reply