[Libwebsockets] Client close example

Andy Green andy at warmcat.com
Wed Apr 26 00:11:46 CEST 2017



On April 26, 2017 6:02:25 AM GMT+08:00, Brenton Rothchild <brentonr at dorm.org> wrote:
>Hi,
>
>I've tried looking for examples on this list or in documentation, but
>so
>far I cannot find a good answer to the following question:
>
>Can someone give a good example (simple, single threaded) where the
>client
>sends a closing
>reason to a WS server (any kind) with a reason using
>lws_close_reason()?
>
>I am finding that with v2.1.0 and v2.2.1, I get sporadic results where
>sometimes callling lws_close_reason() and returning -1 from the
>callback
>will not actually send the close message payload and the socket is
>never
>closed (as viewed using tcpdump).
>
>I'm fairly positive I'm simply not using the library correctly, and
>would
>very much appreciate a
>concrete example where the client is closing the connection with a
>close
>reason.

Run libwebsockets-test-server, visit http://localhost:7681, go to the 'close testing' tab and use the open and close buttons there.  The sources are in ./test-server.

There are no guarantees the peer hasn't already closed the tcp connection, and it's legal for either side to close the connection with no warning at any time.

If there's a gap in the close logic under some circumstances, you'll need to capture more info on how to reproduce.

-Andy

>Thanks!
>-Brenton



More information about the Libwebsockets mailing list