Skip to content

Allow refusing all client connections with max_conns: 0#7877

Merged
neilalexander merged 1 commit intomainfrom
neil/maxconns
Feb 25, 2026
Merged

Allow refusing all client connections with max_conns: 0#7877
neilalexander merged 1 commit intomainfrom
neil/maxconns

Conversation

@neilalexander
Copy link
Copy Markdown
Member

@neilalexander neilalexander commented Feb 25, 2026

By setting max_conns to 0, we will refuse all client, MQTT and WebSocket connections. On reloading max_conns to 0, we will disconnect all clients.

Signed-off-by: Neil Twigg neil@nats.io

@neilalexander neilalexander marked this pull request as ready for review February 25, 2026 10:30
@neilalexander neilalexander requested review from a team as code owners February 25, 2026 10:30
Copy link
Copy Markdown
Member

@MauriceVanVeen MauriceVanVeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Principally LGTM, but should the server config be max_conns: 0?

The users generally know -1 to mean 'infinite', so having max_conns: -1 might be interpreted as "allow infinite connections".
We could detect max_conns is explicitly set to 0 and update the internal opts.MaxConn to -1 still, but then at least it's a bit clearer that max_conns: 0 actually means "no connections allowed" and the internal opts.MaxConn: 0 still means "default connections".

Signed-off-by: Neil Twigg <neil@nats.io>
@neilalexander neilalexander changed the title Allow refusing all client connections with max_conns: -1 Allow refusing all client connections with max_conns: 0 Feb 25, 2026
@neilalexander
Copy link
Copy Markdown
Member Author

Updated so that you can do so with max_conns: 0 instead. Note this doesn't prevent getting the same effect with -1, as there's no "unlimited" when it comes to max_conns (otherwise you'd likely hit the file descriptor limit).

Copy link
Copy Markdown
Member

@MauriceVanVeen MauriceVanVeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@neilalexander neilalexander merged commit f7f2d11 into main Feb 25, 2026
90 of 92 checks passed
@neilalexander neilalexander deleted the neil/maxconns branch February 25, 2026 11:55
neilalexander added a commit that referenced this pull request Feb 25, 2026
Includes the following:

- #7867
- #7865
- #7870
- #7874
- #7877

Signed-off-by: Neil Twigg <neil@nats.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants