[Libwebsockets] LWS_CALLBACK_CLIENT_CONNECTION_ERROR handling with external polling?

Andy Green andy at warmcat.com
Mon Jan 18 20:41:40 CET 2016



On January 19, 2016 3:28:42 AM GMT+08:00, Andy Green <andy at warmcat.com> wrote:
>
>
>On January 19, 2016 1:31:01 AM GMT+08:00, Matt Sarnoff
><matt.sarnoff at gmail.com> wrote:
>>Thanks, Andy. libuv (what I'm using) and libev seem to have diverged a
>>few
>>years ago, and unfortunately I'm not familiar enough with the latter
>to
>>code something worth sharing. :p
>>
>>It would be cool if the library used the callback to
>>register/unregister
>>timeout handlers, similar to how
>>LWS_CALLBACK_{ADD/DEL/CHANGE_MODE}_POLL_FD
>>are used. The libcurl multi API provides a similar feature--the
>>CURLMOPT_TIMERFUNCTION option allows an API consumer to register a
>>custom
>>timeout handler.
>
>libev is directly supported in the library, using libev apis to do the
>related stuff if selected at build-time and runtime.  Assuming this
>problem affects libev too, it should be solved using libev apis.  My

Hm libev support as written in the test-server-libev works with timeouts fine, I just checked it.

You can call lws_service_fd(context, NULL) every second or so from your code to get timeout processing done if that's the only problem.

-Andy

>guess is if the rest of the apis are compatible with libuv something to
>do timeout checks once per second will also be compatible.
>
>Nothing else about libev support is abstracted through callbacks and in
>lws, timeout == close.
>
>-Andy
>
>>Thanks,
>>-matt
>>
>>
>>
>>On Sun, Jan 17, 2016 at 8:02 PM, Andy Green <andy at warmcat.com> wrote:
>>
>>>
>>>
>>> On January 17, 2016 8:53:17 AM GMT+08:00, Matt Sarnoff <
>>> matt.sarnoff at gmail.com> wrote:
>>> >I'm currently using libwebsockets 1.6.0 in a client application
>with
>>an
>>> >external polling mechanism provided by a libuv event loop. I'm not
>>> >calling
>>> >lws_service() at all.
>>> >
>>> >I'm finding that I never receive
>>LWS_CALLBACK_CLIENT_CONNECTION_ERROR
>>> >for
>>> >connection timeouts, e.g. if I specify a nonexistent host name. If
>I
>>> >call
>>> >lws_service() in a loop, I receive the callback after about 5
>>seconds,
>>> >as
>>> >expected.
>>> >
>>> >My current solution involves calling lws_client_connect_via_info(),
>>> >then
>>> >calling lws_service() periodically from a uv_timer_t
>>> >until LWS_CALLBACK_CLIENT_ESTABLISHED is received or the connection
>>> >fails.
>>> >Is there a better way to handle this scenario?
>>>
>>> The guy who added the basic libev support left a comment that
>>somebody
>>> should implement timeouts using libev api, I guess that is what he
>>meant.
>>>
>>> In the service code once a second he will check everyone to see if
>>they
>>> crossed a timeout limit.  But the libev code as you say deals with
>>events
>>> only in the libev realm.
>>>
>>> Can you share your existing code for this and I'll try to integrate
>>it on
>>> the library side, just for timeout processing.
>>>
>>> -Andy
>>>
>>> >
>>> >Thanks,
>>> >-matt
>>> >
>>> >
>>>
>>>------------------------------------------------------------------------
>>> >
>>> >_______________________________________________
>>> >Libwebsockets mailing list
>>> >Libwebsockets at ml.libwebsockets.org
>>> >http://ml.libwebsockets.org/mailman/listinfo/libwebsockets
>>>
>>>
>
>_______________________________________________
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org
>http://ml.libwebsockets.org/mailman/listinfo/libwebsockets




More information about the Libwebsockets mailing list