[Libwebsockets] lws_close_reason with "Max connection reached" message

Thomas Spitz thomas.spitz at hestia-france.com
Wed Jul 6 11:27:22 CEST 2016

When my lws server has reached its maximum of client, I am closing the
connection abruptly using return -1 on LWS_CALLBACK_ESTABLISHED.

I would like to give some further information to the client for the reason
why I do that.
I am trying to use lws_close_reason in the following way:

> unsigned char * closeReasonData = "MAX CONNECTION REACHED!";
> lws_close_reason(wsi,LWS_CLOSE_STATUS_NORMAL,closeReasonData,sizeof(closeReasonData));

But I get the following error:

> ws_close_reason: Assertion `wsi->mode == LWSCM_WS_SERVING || wsi->mode ==
> LWSCM_WS_CLIENT' failed.

 I suppose I have to set LWSCM_WS_SERVING somewhere?
By the way is it appropriate to use LWS_CLOSE_STATUS_NORMAL and data for
this "Max connextion reached" purpose?

I am using master 2.0.0 from 2016/07/16

Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://libwebsockets.org/pipermail/libwebsockets/attachments/20160706/7dcc1350/attachment.html>

More information about the Libwebsockets mailing list