[Libwebsockets] timeout on ws client connect?

Andy Green andy at warmcat.com
Sat Jan 26 17:43:51 CET 2019



On January 26, 2019 9:29:00 PM GMT+08:00, Dave Horton <daveh at beachdognet.com> wrote:
>I am running into an issue where I try to connect to a disfunctional
>server (a non-lws server that I was running a load test against, and it
>seemed at some point to fail over), and the connect attempt seemed to
>just hang — I never got either a LWS_CALLBACK_CLIENT_ESTABLISHED or a
>LWS_CALLBACK_CLIENT_CONNECTION_ERROR as far as I can tell.
>
>I’m wondering — is there a way for me to either configure a connect
>timeout when using lws_client_connect_via_info, or alternatively cause
>a long-running connection to fail from another thread.
>
>Also - am I guaranteed to get either LWS_CALLBACK_CLIENT_ESTABLISHED or
>a LWS_CALLBACK_CLIENT_CONNECTION_ERROR every time I call
>lws_client_connect_via_info, even it it returns 0 ?

The client tcp connection attempts happen asynchronously and nonblocking, and are always subject to an lws timeout.

If a connection times out without having completed the tcp connection, the flow that closes it should notice it's an incomplete client connection and do the CONNECTION_ERROR instead of CLOSED.

But if the tcp connect actually completed with this brain-damaged server, but it never responds subsequently, when that part which is also covered by an lws timeout eventually times out, you may get a CLOSED since there was no error with the connection part.

-Andy

>Dave
>_______________________________________________
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org
>https://libwebsockets.org/mailman/listinfo/libwebsockets


More information about the Libwebsockets mailing list