[Libwebsockets] libwebsocket problem

Andy Green andy at warmcat.com
Thu May 23 13:30:34 CEST 2019

On 5/23/19 7:32 AM, Wei, Catherine wrote:

> Thanks, the api that you offered works in my case mentioned in my
> early email. Calling it when I disconnect the connection from server
> side will disconnect the connection and also send callback to the
> server in my case.


> However, in another case, I found that when a client request a
> connection, the websocket server will receive a callback to handle
> the new connection. When the server handles the new connection, it
> rejects the connection directly by the api lws_set_timeout(). At this
> time, when I disconnect the connection from the server side using api
> lws_set_timeout() when the client request a connection will lead to
> libwebsocket crash. The process in detail: 1,Client request a
> connection   ->libwebsocket 2.Server HandleNewConnection callback,
> and call "lws_set_timeout()", then the process of websocket server
> will report segment fault error like follow:

You don't mention the callback reason nor show the code.

You're using LWS_TO_KILL_ASYNC, right?

#define LWS_TO_KILL_ASYNC -1
/**< If LWS_TO_KILL_ASYNC is given as the timeout sec in a lws_set_timeout()
  * call, then the connection is marked to be killed at the next timeout
  * check.  This is how you should force-close the wsi being serviced if
  * you are doing it outside the callback (where you should close by nonzero
  * return).
#define LWS_TO_KILL_SYNC -2
/**< If LWS_TO_KILL_SYNC is given as the timeout sec in a lws_set_timeout()
  * call, then the connection is closed before returning (which may delete
  * the wsi).  This should only be used where the wsi being closed is 
not the
  * wsi currently being serviced.


More information about the Libwebsockets mailing list