[Libwebsockets] controlled client initated close
otto at drijf.net
Fri Dec 15 16:35:36 CET 2017
On Mon, Dec 11, 2017 at 11:36:29AM +0100, Otto Moerbeek wrote:
> I have a websocket that is operating properly, but I would like to
> close the websocket in a proper way if the client is about to quit.
> So what I'm doing in the client is:
> lws_close_reason(wsi, LWS_CLOSE_STATUS_GOINGAWAY, NULL, 0);
> return -1 from the user callback on LWS_CALLBACK_CLIENT_WRITEABLE.
> That indeed initates a close, but it seems to be a hard TCP socket
> close; the server sees:
> CloseReason: code , reason [null]
> 1006 is LWS_CLOSE_STATUS_ABNORMAL_CLOSE, so the client is not doing a
> controlled close.
> Am I doing something wrong here? What is the proper way to initate a
> websocket close by a client?
To reply to myself ith some more info:
I managed to do a proper client-initialed shutdown using
This is of course against the API, but as said, using
lws_close_reason() does not works for me with both libwebsockets 2.3.0
More information about the Libwebsockets