[Libwebsockets] Client App | Recreating websocket connection faster

Harshad Italiya harshaditaliya at gmail.com
Mon Jul 18 06:22:15 CEST 2016


Andy:

Thank you for the suggestion. After your suggestion I looked into
test-client.c and I get to know about checking the version and I can see
the one I was using was *1.6.0 *while the latest one is I think *2.0.0 *
correct?
Is *2.0.0* is the latest stable release? I am going to check my logic and
will try to change it to make similar to test-client.c and will update how
it goes.

Thank you.

On Sat, Jul 16, 2016 at 4:53 PM, Andy Green <andy at warmcat.com> wrote:

>
>
> On July 16, 2016 7:03:54 PM GMT+08:00, Harshad Italiya <
> harshaditaliya at gmail.com> wrote:
> >Hello,
> >
> >I am using libwebsocket and I have created client application. I am
> >using
> >GSM modem in my system for internet connectivity and because of that
> >there
> >are many times I am loosing GPRS and I have implemented my application
> >in
> >such a way so if there is GPRS lost then I am closing the connection
> >by *"lws_context_destroy(lws_context)"
>
> No... that destroys the whole context.
>
> You'd do that when your app was closing.
>
> >*this can also be in case when there is something wrong between client
> >and
> >server custom protocol communication missing.
> >
> >I have seen when I am closing connection when GPRS is lost and then
> >it's
> >back but not able to create a connection with server. While if I
> >restart
> >application then it gets connect fine.
> >
> >Is wait required after *lws_context_destroy* function call and before
> >calling *lws_client_connect function*.
>
> No... closing a connection is a different animal.
>
> create context {
>
>   connect and close connections as many times as you like
>
> } destroy context
> exit program
>
>
> There are two valid ways to close client connections... return nonzero
> from most callbacks, or set the timeout on the wsi to, eg, -1.
>
> More importantly look at the test client in ./test-server/test-client.c
> and follow how that works, if you did that you would see destroying the
> context happens when it exits, although it closes and creates connections
> many times (eg mirror connections last for a random 'lifetime' and then
> reconnect).
>
> -Andy
>
> >Regards,
> >
> >
> >------------------------------------------------------------------------
> >
> >_______________________________________________
> >Libwebsockets mailing list
> >Libwebsockets at ml.libwebsockets.org
> >http://libwebsockets.org/mailman/listinfo/libwebsockets
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20160718/ddab7d70/attachment-0001.html>


More information about the Libwebsockets mailing list