rumqtt icon indicating copy to clipboard operation
rumqtt copied to clipboard

Keep-alive rejection

Open pascaldekloe opened this issue 10 months ago • 2 comments

    // When keep_alive feature is disabled client can live forever, which is not good in
    // distributed broker context so currenlty we don't allow it.
    if connect.keep_alive == 0 {
        return Err(Error::ZeroKeepAlive);
    }

Such behaviour deviates from the 3.1.1 specification:

A Keep Alive value of zero (0) has the effect of turning off the keep alive mechanism. This means that, in this case, the Server is not required to disconnect the Client on the grounds of inactivity. Note that a Server is permitted to disconnect a Client that it determines to be inactive or non-responsive at any time, regardless of the Keep Alive value provided by that Client.

The server may enforce it's own keep-alive when zero, yet it may not deny clients that wish to abstain from PING obligations.

pascaldekloe avatar Feb 17 '25 16:02 pascaldekloe

The handle_auth routine before ignores the keep-alive value. How about a sane default of 30 seconds or something like that?

pascaldekloe avatar Feb 17 '25 17:02 pascaldekloe

@pascaldekloe instead of rejecting clients with keep_alive 0 , we can handle clients with 0 keep_alive by enforcing a default value (probably little higher) to lower its bandwidth utilization. for V5 clients we can return server_keep_alive in connack packet

giridher-art avatar Sep 04 '25 06:09 giridher-art