[Libwebsockets] Closing client connection

Andy Green andy at warmcat.com
Fri Jul 15 08:48:45 CEST 2016


On Fri, 2016-07-15 at 11:54 +0800, Andy Green wrote:
> On Fri, 2016-07-15 at 08:55 +0530, techi eth wrote:
> > I agree with you point that other side is out of lws however server
> > using lws need's to clean himself if he know this kind of stale
> > connection exists.
> 
> Yes, I didn't mean lws isn't affected by it, I meant everything has
> the
> same problem and needs the same basic solution.  Which I agree is a
> good argument for sticking it in the library.
> 
> > One solution you have pointed out by sending some data & that will
> > fail on TCP & lws will give WSI Destroy.
> > 
> > lws have lot of developer friendly API so that they needn't to add
> > this kind of complex logic & i think adding this will add feature
> > to
> > lws.
> > 
> > If you can give me hint in lws code then i can check for adding &
> > update patch to you.
> 
> Thanks, I appreciate the suggestion and willingness to contribute.
> 
> I started to write up what it would look like, but I think maybe I
> should better have a go at it since it needs some thought about how
> to
> efficiently handle te interval detection for idle connections.
>  They're
> after all not producing events (that's the point) and there might be
> a
> lot of them.  The main guts of it should be handled by existing PING
> /
> PONG and the existing timeout mechanism, which is a linked-list on
> master.
> 
> Let me take a look in the next hours and I'll reply with what's
> happened later.

Please give this on master a try

https://github.com/warmcat/libwebsockets/commit/4a45b59cd9018dd78f34198
8ad648cfd24d4c9a8

-Andy


> -Andy
> 
> 
> > On Wed, Jul 13, 2016 at 5:47 PM, Andy Green <andy at warmcat.com>
> > wrote:
> > > 
> > > On July 13, 2016 1:17:29 AM GMT+08:00, techi eth <techieth at gmail.
> > > co
> > > m> wrote:
> > > > I am facing issue when client close without informing server
> > > (Power
> > > > Off/Application Crash/Network Down).In that case server side
> > > > still
> > > have
> > > > that connection & i think that connection get broken on
> > > > ping/pong
> > > time.
> > > 
> > > Right, but that is a reality outside of lws.
> > > 
> > > If there is no traffic after the connection was established, and
> > > one side is gone silently, the other side has no reason to think
> > > he's not still there, but silent.
> > > 
> > > You send the other guy something periodically to confirm he's
> > > silent because he has nothing to say, not that he's dead / gone. 
> > > Just sending him something will create the expectation for tcp
> > > ACKs
> > > coming back.
> > > 
> > > > What i am thinking it will be better solution if we have close
> > > > connection
> > > > API so that server application can decide if they want to
> > > > really
> > > close
> > > > connection.
> > > 
> > > When we say 'better' what are we comparing it with?
> > > 
> > > > I was just looking Client/Server support from .Net framework &
> > > found
> > > > they
> > > > will provide close interface to handle this cases.
> > > 
> > > Handle exactly what case?  What is getting fixed?
> > > 
> > > -Andy
> > > 
> > > > 
> > > > 
> > > > 
> > > > On Tue, Jul 12, 2016 at 12:26 PM, Andy Green <andy at warmcat.com>
> > > wrote:
> > > > 
> > > > > On Tue, 2016-07-12 at 11:27 +0530, techi eth wrote:
> > > > > > Is their any API for closing client connection by server ?
> > > > > > 
> > > > > > As of now i am returning non negative value from callback
> > > > > > for
> > > > closing
> > > > > > but some cases where server needs to close client
> > > > > > connection
> > > > without
> > > > > > callback.
> > > > > 
> > > > > Can you explain more about those cases?
> > > > > 
> > > > > It's that lws is just doing serving only, and decides he must
> > > drop
> > > > what
> > > > > was an incoming client connection?  All client connections?
> > > > > 
> > > > > -Andy
> > > > > 
> > > > > > 
> > > > > > _______________________________________________
> > > > > > Libwebsockets mailing list
> > > > > > Libwebsockets at ml.libwebsockets.org
> > > > > > http://libwebsockets.org/mailman/listinfo/libwebsockets
> > > > > 
> > > 
> > > 
> > 
> > _______________________________________________
> > Libwebsockets mailing list
> > Libwebsockets at ml.libwebsockets.org
> > http://libwebsockets.org/mailman/listinfo/libwebsockets
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://libwebsockets.org/mailman/listinfo/libwebsockets



More information about the Libwebsockets mailing list