[Libwebsockets] Nodejs to libwebsockets

Andy Green andy at warmcat.com
Thu Apr 4 06:23:03 CEST 2019

On April 4, 2019 12:08:05 PM GMT+08:00, Paolo Denti <paolo.denti at gmail.com> wrote:
>I am trying to migrate the code below, from node.js to libwebsockets (i
>oversimplified it removing all the boilerplate code)
>Basically I need to connect, send some data and stay connected, forever
>I tried to find the closest option possible in the minimal examples but
>actually I am not able to replicate the behavior using any of the

Well, they are minimal examples for particular cases.  For real code, you might have to mix and match.

>Could anyone point me to the right direction?

This shows how to do the 'nailed up client connection' and is a good starting point.


>var Stomp = require('stompjs');
>var connect_callback = function() {
>client.send("/ws/xx/yy/zz", {}, JSON.stringify({token: sample
>var client = Stomp.overWS('wss://<my server>/<my websocket endpoint>');
>client.connect({}, connect_callback);

It looks like this doesn't specify a subprotocol, which is pretty craptastic.

Lws can do it if you leave the client connection protocol NULL.


That example doesn't use tls... you'll need to set this accordingly


and the context / vhost options like this



More information about the Libwebsockets mailing list