emqx / esockd

Erlang general non-blocking TCP/SSL socket server
https://www.emqx.com
Apache License 2.0
211 stars 84 forks source link

fix: enhance connection rate limit #196

Closed zmstone closed 2 weeks ago

zmstone commented 3 weeks ago

Fixes: https://github.com/emqx/emqx/issues/14145

Prior to this change, if connection rate is limited, the acceptors will enter suspending state and stop accepting the sockets leaving the sockets in the system backlog.

If the acceptor backlog (default=1024) is filled up, for long enough time to cause the majority of the clients to have closed socket from their end and try to reconnect aggressively, the acceptor may never be able to get a normal socket again.

The fix is: in suspending state, accept the sockets and immediately close them to free up the backlog. The close triggers TCP-RST to cut the TCP graceful close overheads.