[Libwebsockets] What is the correct way to close a WS client connection?
olivier at olivierlanglois.net
Fri May 8 23:44:34 CEST 2020
I want to implement an inactivity timer because my WS client has just
sit idle since I have rebooted my router at home yesterday evening.
I want lws to initiate a WS client close so that the lws callbacks
trigger my reconnection code.
By trying to plan how I'll do that, I have figure that beside when I
shutdown the process and clean-up lws, that is the only way that I
currently initiate a connection shutdown. Beside that unique situation,
I simply react passively to events received in the callback to process
reconnections when lws reports a connection error or that the server
close the connection.
What is the function to call to let lws know that we want to close a ws
In lws-client.h where the connect function is, there is no equivalent
close function. There is also a lws-ws-close.h providing a
lws_close_reason(). It isn't 100% clear lws_close_reason() actually
perform the close. It is used by the library and it seems to be for
setting the reason after the fact that something did trigger a
A little help for this simple issue would be welcome.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libwebsockets