[Libwebsockets] libwebsocket problem

Wei, Catherine catherine.wei at commscope.com
Fri May 17 04:48:58 CEST 2019

Thanks, if I use the lws_hdr_copy_fragment, I need to know how many fragments; if I use lws_get_urlarg_by_name, I need to know parameter name. However, all these are unknown to me. I think comment out the parse about "?" in the path seems the most simple and direct way to me. I will use this way for debug at present, but still thanks for your suggestion and letting me know such interfaces.

Another problem that I met:
When I want to disconnect the websocket connection (protocol: ws) using the "close(lws_get_socket_fd(&lwsConnection));" from the websocket server side, I found there is no callback with reason (LWS_CALLBACK_DEL_POLL_FD) coming, and without this, the file descriptor will not be removed. If I manually exit the running websocket client, I can receive the callback with reason LWS_CALLBACK_WSI_DESTROY and LWS_CALLBACK_DEL_POLL_FD.

Do you know why this happened?

Best regards,

-----Original Message-----
From: Andy Green <andy at warmcat.com> 
Sent: 2019年5月16日 18:19
To: Wei, Catherine <catherine.wei at commscope.com>; libwebsockets at ml.libwebsockets.org
Subject: Re: [Libwebsockets] libwebsocket problem

Email Security Warning:

The following message was sent from an external e-mail address. Exercise caution when opening attachments, clicking links, or exchanging information.

On 5/16/19 9:12 AM, Wei, Catherine wrote:
> Thanks for the API, since the number of the parameters are also unknow, so I didn't use the API. I added a patch to keep the parameters to the url, so I can easily get the request url with parameters with current interface. Still thanks. By the way, if there is any unproper place in my patch, please let me know.

I appreciate the urge to send me code, but the existing apis can do everything you needed... look at the implementation of the by_name() api... it's based on the other api.  It just looks at each fragment until it finds it has asked for one that doesn't exist.

lws_get_urlarg_by_name(struct lws *wsi, const char *name, char *buf, int
         int n = 0, sl = (int)strlen(name);

         while (lws_hdr_copy_fragment(wsi, buf, len,
                           WSI_TOKEN_HTTP_URI_ARGS, n) >= 0) {

                 if (!strncmp(buf, name, sl))
                         return buf + sl;


         return NULL;



More information about the Libwebsockets mailing list