[Libwebsockets] Forced disconnect for chocked connections
andy at warmcat.com
Wed May 18 11:48:02 CEST 2016
On 05/18/2016 05:37 PM, Andrejs Hanins wrote:
> As per documentation, one needs to enable TCP keep-alive to be able
> to deal with chocked connection (not writable sockets), but in my
> design there is a higher level timeouts which may request to close a
> WS connection. Those close requests don't come from the LWS
> callbacks, so I can't directly return -1 to LWS and need to request
> writable callback which will never come if the connection is
Hum I think in other words it's suggesting "close from another thread"
which can't fly. But I do see the point.
> I'm thinking about some new API which will give a way to close a
> socket from outside of the LWS callbacks despite any chocked state.
> Andy, others, do you think it could be a valuable improvement? I
> don't really like that TCP keep-alive is the only way to deal with
> chocked connections, especially when there are other higher level
> timeouts implemented in use code.
Yes I do think there's something to add here.
But maybe it's about adding auto-PING/PONG timeouts on idle connections.
There's no point sending PINGs on active connections since to stay
active, he has to be getting the remote ACKs.
If a connection remains choked for a long time, in other words no TCP
ACKs are coming, which implies no traffic is passing or the guy
consuming the data is deadlocked, either way it's necessary he should be
forcibly closed from the server side after a while.
Lws timeouts (synchronously, within the service thread framework) can do
the business end of that OK.
Maybe what's needed is associate "send a ws PING if this connection has
been idle for n sec" and "set an lws timeout when you send the PING"
that is cleared by the PONG receipt.
Because there are many "invisible" ills that might befall the remote
peer or its interconnection that can't otherwise be determined.
Will this solve your problem?
> BR, Andrey _______________________________________________
> Libwebsockets mailing list Libwebsockets at ml.libwebsockets.org
More information about the Libwebsockets