[Libwebsockets] Closing connection from server side

Andy Green andy at warmcat.com
Thu Dec 17 18:02:30 CET 2015



On December 17, 2015 10:47:07 PM GMT+08:00, Mauro Cigala <mairo.87.me at gmail.com> wrote:
>Hello,
>I'm using the v. 1.5 of the lib and I need to close the websocket
>connection from server side as soon as it's established.
>I try to do it returning -1 in the LWS_CALLABACK_ESTABLISHED, but the
>callback LWS_CALLBACK_CLOSED in the client side is not trigged.
>What is the right way to do that?
>Do I need to call lws_callback_on_writable() and here return -1?

Yeah it's a bug, the result of the callback for established was not checked until now.

>What is the right way to do that?

It hasn't mattered because there is an earlier point that is checked, which has all the client headers still, LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION.  You should probably use that, which comes before the server handshakes the ws upgrade.

-Andy

>Thanks,
>Mauro
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org
>http://ml.libwebsockets.org/mailman/listinfo/libwebsockets




More information about the Libwebsockets mailing list