[Libwebsockets] Nodejs to libwebsockets

Paolo Denti paolo.denti at gmail.com
Thu Apr 4 06:28:38 CEST 2019

Thank you Andy
I’ll look through the referenced examples

Just FYI, using the stompjs nodejs library, the default subprotocols, for
negotiation, are the ones defined as default in the library, that
are ['v10.stomp', 'v11.stomp’].
And I removed it for clarity from the code

On April 3, 2019 at 9:23:09 PM, Andy Green (andy at warmcat.com) wrote:

On April 4, 2019 12:08:05 PM GMT+08:00, Paolo Denti <paolo.denti at gmail.com>
>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

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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20190403/9ec4272d/attachment.htm>

More information about the Libwebsockets mailing list