[Libwebsockets] How to "disconnect"?

Andy Green andy at warmcat.com
Tue Jul 29 23:46:38 CEST 2014



On 30 July 2014 01:45:30 GMT+08:00, Mike M <lws14 at mordent.com> wrote:
>I think this is what keepalive is for when you create the context.

Keepalive can help with detecting packets are no longer getting through.

About the client lifecycle part of the question the test client does something similar, he repeatedly closes the connection after a random time (by returning nonzero from a callback) and when he sees he's dead in the main service loop, just calls client connect again to get a new connection.  The context is unaffected.

So you should be able to do what uou're looking for the same way.

-Andy

>-m
>
>
>On 07/29/2014 11:44 AM, Carlos Sánchez wrote:
>> I've make a client application that is working fine (since now) but 
>> testing communication issues I've reached a point where I can't solve
>
>> a connection problem.
>> Once connected and after many data exchange without problems, I've 
>> disconnected the device from the internet without loosing the link 
>> (I've removed the "output" cable of the switch where device is 
>> connected). So, there is no link down detection and libwebsocket 
>> doesn't detect the disconnection from the server. After two minutes, 
>> my "ping" timer fires and sends a LWS_WRITE_PING without any error
>and 
>> of course after another one minute the "pong" timer fires and detect 
>> the missing server connection.
>> I need to "disconnect" and "connect" again ("reconnect"), but I can't
>
>> found the analogous function of libwebsocket_client_connect().
>> How can I force a "disconnect" without destroying the context, and if
>
>> possible reuse the connection?
>>
>
>_______________________________________________
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org
>http://ml.libwebsockets.org/mailman/listinfo/libwebsockets




More information about the Libwebsockets mailing list