[Libwebsockets] LWS_CALLBACK_CLIENT_CONNECTION_ERROR never got triggered

bjorka adinov adinov.bjorka at gmail.com
Mon Apr 27 09:09:40 CEST 2015


Hello,

I checked the windows part code and apparently the callback is indeed not
called when lws client timeouts after trying to connect to non listening
socket. Is this by design or something need to be fixed ?

Thanks

On Thu, Apr 16, 2015 at 6:57 PM, Andy Green <andy at warmcat.com> wrote:

>
>
> On 16 April 2015 17:30:40 GMT+08:00, bjorka adinov <
> adinov.bjorka at gmail.com> wrote:
> >Hello,
> >
> >I have a problem. I have client - server application, both utilizing
> >libwebsockets. The usual scenario is whenever the client application
> >active, it will try to connect to the server automatically. The client
> >use libwebsocket_client_connect() to connect. As stated in the readme,
> >the
> >client has to wait for LWS_CALLBACK_CLIENT_CONNECTION_ERROR to know
> >that
> >the connection attempt has failed. Unfortunately when the server isn't
> >active yet, LWS_CALLBACK_CLIENT_CONNECTION_ERROR never got triggered
> >even
> >after 5 second, so the client can't clean up properly. I have tried
> >this
> >using the samples and the result is the same.
>
> Hm.
>
> >I'm using libwebsockets version 1.4 and ms visual studio 2013. Any
> >response
> >will be appreciated
>
> When you say, "the server isn't active yet", if I try to connect to an IP
> with no listening server socket, lws test client errors out immeditely,
> which makes sense because there is a socket error immediately
>
> [agreen at build build]$ libwebsockets-test-client  localhost
> libwebsockets test client
> (C) Copyright 2010-2015 Andy Green <andy at warmcat.com> licensed under
> LGPL2.1
> [1429184098:8952] NOTICE: Initial logging level 7
> [1429184098:8952] NOTICE: Library version: 1.4 c7378d8
> [1429184098:8952] NOTICE: IPV6 not compiled in
> [1429184098:8952] NOTICE: libev support not compiled in
> [1429184098:8953] NOTICE:  static allocation: 4536 + (16 x 1024 fds) =
> 20920 bytes
> [1429184098:8953] NOTICE:  canonical_hostname = build.warmcat.com
> [1429184098:8953] NOTICE:  per-conn mem: 248 + 2140 headers + protocol rx
> buf
> Waiting for connect...
> LWS_CALLBACK_CLIENT_CONNECTION_ERROR
> Exiting
> [1429184098:9151] NOTICE: libwebsocket_context_destroy
>
> If you mean he's listening but nonresponsive, like this
>
> diff --git a/test-server/test-server.c b/test-server/test-server.c
> index b321ff8..91d430a 100644
> --- a/test-server/test-server.c
> +++ b/test-server/test-server.c
> @@ -924,6 +924,9 @@ int main(int argc, char **argv)
>                 return -1;
>         }
>
> +
> +       sleep(10000);
> +
>         n = 0;
>         while (n >= 0 && !force_exit) {
>                 struct timeval tv;
>
> The client times out properly
>
> [agreen at build build]$ libwebsockets-test-client  localhost -d65535
> libwebsockets test client
> (C) Copyright 2010-2015 Andy Green <andy at warmcat.com> licensed under
> LGPL2.1
> [1429184685:6858] NOTICE: Initial logging level 65535
> [1429184685:6858] NOTICE: Library version: 1.4 c7378d8
> [1429184685:6858] NOTICE: IPV6 not compiled in
> [1429184685:6858] NOTICE: libev support not compiled in
> [1429184685:6858] INFO:  LWS_MAX_HEADER_LEN: 1024
> [1429184685:6858] INFO:  LWS_MAX_PROTOCOLS: 5
> [1429184685:6858] INFO:  SPEC_LATEST_SUPPORTED: 13
> [1429184685:6858] INFO:  AWAITING_TIMEOUT: 5
> [1429184685:6858] INFO:  SYSTEM_RANDOM_FILEPATH: '/dev/urandom'
> [1429184685:6858] INFO:  LWS_MAX_ZLIB_CONN_BUFFER: 65536
> [1429184685:6858] NOTICE:  static allocation: 4536 + (16 x 1024 fds) =
> 20920 bytes
> [1429184685:6859] INFO:  LWS_MAX_EXTENSIONS_ACTIVE: 3
> [1429184685:6859] NOTICE:  canonical_hostname = build.warmcat.com
> [1429184685:6859] NOTICE:  per-conn mem: 248 + 2140 headers + protocol rx
> buf
> [1429184685:7090] PARSER:   Protocol:
> dumb-increment-protocol,fake-nonexistant-protocol
> [1429184685:7091] PARSER:   Protocol:
> fake-nonexistant-protocol,lws-mirror-protocol
> [1429184685:7091] CLIENT: libwebsocket_client_connect: direct conn
> [1429184685:7092] CLIENT: libwebsocket_client_connect_2
> [1429184685:7092] CLIENT: libwebsocket_client_connect_2: address localhost
> [1429184685:7097] INFO: insert_wsi_socket_into_fds: wsi=0x1999f70, sock=6,
> fds pos=1
> [1429184685:7099] CLIENT: nonblocking connect retry
> Waiting for connect...
> [1429184685:7099] CLIENT: libwebsocket_client_connect_2
> [1429184685:7100] CLIENT: libwebsocket_client_connect_2: address localhost
> [1429184685:7101] CLIENT: connected
> [1429184685:7102] CLIENT: libwebsocket_client_connect: direct conn
> [1429184685:7103] CLIENT: libwebsocket_client_connect_2
> [1429184685:7103] CLIENT: libwebsocket_client_connect_2: address localhost
> [1429184685:7104] INFO: insert_wsi_socket_into_fds: wsi=0x199a120, sock=7,
> fds pos=2
> [1429184685:7106] CLIENT: nonblocking connect retry
> [1429184685:7106] CLIENT: libwebsocket_client_connect_2
> [1429184685:7107] CLIENT: libwebsocket_client_connect_2: address localhost
> [1429184685:7108] CLIENT: connected
> [1429184691:0046] INFO: TIMEDOUT WAITING on 4
> [1429184691:0046] DEBUG: close: just_kill_connection
> [1429184691:0046] INFO: remove_wsi_socket_from_fds: wsi=0x1999f70, sock=6,
> fds pos=1
> [1429184691:0046] DEBUG: not calling back closed
> [1429184692:0104] INFO: TIMEDOUT WAITING on 4
> [1429184692:0104] DEBUG: close: just_kill_connection
> [1429184692:0104] INFO: remove_wsi_socket_from_fds: wsi=0x199a120, sock=7,
> fds pos=1
> [1429184692:0104] DEBUG: not calling back closed
>
> So there's no huge problem like he is stuck.
>
> However you are right, he doesn't call back appropriately under those
> conditions.
>
> I pushed a patch that makes him do the callback if he meets that
> situation.  Thanks for letting me know.
>
> -Andy
>
> >Thanks
> >
> >
> >------------------------------------------------------------------------
> >
> >_______________________________________________
> >Libwebsockets mailing list
> >Libwebsockets at ml.libwebsockets.org
> >http://ml.libwebsockets.org/mailman/listinfo/libwebsockets
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20150427/9833d887/attachment-0001.html>


More information about the Libwebsockets mailing list