ezsockets icon indicating copy to clipboard operation
ezsockets copied to clipboard

A few suggestions in regards to connection management

Open asn007 opened this issue 7 months ago • 3 comments

Hey there! After using ezsockets for our software, which utilises websockets heavily, I've found a few suggestions regarding connection management algorithms that could potentially be merged into mainline ezsockets.

Let me know how those suggestions look to you

  1. A reconnection attempt when a socket dies while establishing connection, or can not be opened should respect retry timeout as well, otherwise we're risking a potential DoS attack of a WS server (or increased resource consumption on host machine)
  2. Right now when the keepalive process does not receive a heartbeat packet in time - it closes the socket with reason normal. Seems to me that losing heartbeat is anything but normal, but I might be mistaken. Potentially change it to error?
  3. When a socket is put in a hangup state, say, by changing IP addresses on a host machine (it stays ESTABLISHED, but is in fact dead until IPs change back) - the client silently dies. I've changed that in my fork to force the socket cleanup - seems like socket hangup in that case is not really intended behaviour

Note: I haven't had the chance to use the server side, those suggestions only apply client-side

If those look good I can make a few separate PRs with the changes proposed

asn007 avatar Jul 12 '24 20:07 asn007