[Libwebsockets] LWS_CALLBACK_CLIENT_CONNECTION_ERROR handling with external polling?

Andy Green andy at warmcat.com
Mon Jan 18 20:28:42 CET 2016

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
>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
>timeout handlers, similar to how
>are used. The libcurl multi API provides a similar feature--the
>CURLMOPT_TIMERFUNCTION option allows an API consumer to register a
>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 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.


>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
>> >external polling mechanism provided by a libuv event loop. I'm not
>> >calling
>> >lws_service() at all.
>> >
>> >I'm finding that I never receive
>> >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
>> >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
>> should implement timeouts using libev api, I guess that is what he
>> In the service code once a second he will check everyone to see if
>> crossed a timeout limit.  But the libev code as you say deals with
>> 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

More information about the Libwebsockets mailing list