<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body><div style="font-family:Helvetica,Arial;font-size:13px">Thank you Andy</div><div style="font-family:Helvetica,Arial;font-size:13px">I’ll look through the referenced examples</div><div style="font-family:Helvetica,Arial;font-size:13px"><br></div><div style="font-family:Helvetica,Arial;font-size:13px">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’].</div><div style="font-family:Helvetica,Arial;font-size:13px">And I removed it for clarity from the code</div> <div class="gmail_signature"></div> <br><p class="airmail_on">On April 3, 2019 at 9:23:09 PM, Andy Green (<a href="mailto:andy@warmcat.com">andy@warmcat.com</a>) wrote:</p> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>
<br>
<br>On April 4, 2019 12:08:05 PM GMT+08:00, Paolo Denti <<a href="mailto:paolo.denti@gmail.com">paolo.denti@gmail.com</a>> wrote:
<br>>Hi,
<br>>I am trying to migrate the code below, from node.js to libwebsockets (i
<br>>oversimplified it removing all the boilerplate code)
<br>>Basically I need to connect, send some data and stay connected, forever
<br>>
<br>>I tried to find the closest option possible in the minimal examples but
<br>>actually I am not able to replicate the behavior using any of the
<br>>existing
<br>>samples.
<br>
<br>Well, they are minimal examples for particular cases.  For real code, you might have to mix and match.
<br>
<br>>Could anyone point me to the right direction?
<br>
<br>This shows how to do the 'nailed up client connection' and is a good starting point.
<br>
<br><a href="https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c">https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c</a>
<br>
<br>>Thanks
<br>>
<br>>var Stomp = require('stompjs');
<br>>
<br>>var connect_callback = function() {
<br>>client.send("/ws/xx/yy/zz", {}, JSON.stringify({token: sample
<br>>data""}));
<br>>};
<br>>
<br>>var client = Stomp.overWS('wss://<my server>/<my websocket endpoint>');
<br>>client.connect({}, connect_callback);
<br>
<br>It looks like this doesn't specify a subprotocol, which is pretty craptastic.
<br>
<br>Lws can do it if you leave the client connection protocol NULL.
<br>
<br><a href="https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c#n96">https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c#n96</a>
<br>
<br>That example doesn't use tls... you'll need to set this accordingly
<br>
<br><a href="https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c#n94">https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/ws-client/minimal-ws-client-pmd-bulk/protocol_lws_minimal_pmd_bulk.c#n94</a>
<br>
<br>and the context / vhost options like this
<br>
<br><a href="https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/ws-client/minimal-ws-client-echo/minimal-ws-client-echo.c#n141">https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/ws-client/minimal-ws-client-echo/minimal-ws-client-echo.c#n141</a>
<br>
<br>-Andy
<br></div></div></span></blockquote></body></html>