[Libwebsockets] Missing callback on connection failure?

Andy Green andy at warmcat.com
Thu Jul 14 07:40:41 CEST 2016

On Thu, 2016-07-14 at 07:20 +0200, Fabian Kurz wrote:
> Hello,
> while using libwebsockets (2.0.0) as a client, on very rare
> occasions my program would "hang up" while trying to establish
> a SSL connection to the server.
> It turned out that the client program still called lws_service()
> as usual and it returned as it should, but apparently it missed a
> callback to tell it that something bad happened. 
> Normally, if something is wrong with the server (no connection
> at all, it doesn't speak websocket or SSL, e. g. during deployment
> of a new version on the server), I get either
> which my client handles properly and then tries to re-connect.
> During those connection failures which caused the hang up, the only
> callback I finally got was LWS_CALLBACK_WSI_DESTROY. I was able
> to reproduce this a few times with full logging enabled and the
> resulting log file is attached. It always happened while something
> was going on at the server - most likely it was restarted exactly
> at the moment of the connection attempt.
> Is this the intended behaviour, or should I get a callback to

No it shoud tell you at least CONNECTION_ERROR and CLOSED if it got far
enough along for that to make sense.

There are some fixes for that on master and v2.0-stable, eg


It's best to use at least v2.0-stable rather than a vX.0 release
because unfortunately many people don't test it until there's a
release, and we hear about the bugs only then.

Master also goes to much greater lengths to provide a string for why
the client connection failed


On master for windows there's also this



> Thanks and best regards,
> Fabian
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://libwebsockets.org/mailman/listinfo/libwebsockets

More information about the Libwebsockets mailing list