Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddStateBagChangeHandler #2413

Open
KiLaF opened this issue Mar 8, 2024 · 6 comments
Open

AddStateBagChangeHandler #2413

KiLaF opened this issue Mar 8, 2024 · 6 comments
Assignees
Labels
bug triage Needs a preliminary assessment to determine the urgency and required action

Comments

@KiLaF
Copy link

KiLaF commented Mar 8, 2024

What happened?

so when their is a rate limit that is putten on state bags that stop makes you barelly can use it when their is multiple players doing so in the same time.
I tried to use state bag to make a contact with the serveur but when im the only connected it works but when multiple players it kicks them of overflow

Expected result

Reduce ratelimit or fix

Reproduction steps

i explained everything up

Importancy

Security issue

Area(s)

FiveM

Specific version(s)

FiveM

Additional information

No response

@KiLaF KiLaF added bug triage Needs a preliminary assessment to determine the urgency and required action labels Mar 8, 2024
@AvarianKnight
Copy link
Contributor

Its very hard to understand what you're saying. Can you provide example code of how you're hitting the state packet overflow

@KiLaF
Copy link
Author

KiLaF commented Mar 9, 2024

Its very hard to understand what you're saying. Can you provide example code of how you're hitting the state packet overflow

I wanted to use it for a contact between client & server instead of TriggerServerEvent

@thorium-cfx
Copy link
Contributor

Reading your explanation I understand that when you enable rate limiting on state bags, you quickly hit the rate limiting limits, correct?

@mcNuggets1
Copy link

"Enable rate limiting"
There is rate limiting?

@thorium-cfx
Copy link
Contributor

There is rate limiting?

Yep, I'll leave that to @nihonium-cfx and @AvarianKnight, not sure if they already made public documentation on it

@AvarianKnight
Copy link
Contributor

There's where a few rate limiters for state bags, they use the same logic as client->server net events.

Each rate limiter can be adjusted via ConVar if you're hitting the rate limits, though these limits are extremely high for defaults and if you're hitting them then I highly recommend you adjust how you're sending them.

These limiters are needed to prevent the possibility of memory exhaustion or to prevent a client from crashing the server you can find more information in #2361

Regular State Bag Limiter

  • rateLimiter_stateBag_rate default value 75 - the amount of state bag change packets that can be sent per second
  • rateLimiter_stateBag_burst default value 125 - the amount that the rate limiter can burst to before hitting the limiter, after hitting this limiter the client will be blocked from changing any state bags for the next second.

Flood State Bag Limiter

  • rateLimiter_stateBagFlood_rate default value 150 - the amount of requests that can be sent per second before it being considered a "flood".
  • rateLimiter_stateBagFlood_burst default value 175 - the amount of requests that the limiter can burst to before hitting the flood kick.

If a client is detected as flooding then they will be dropped from the server so that they don't cause any network issues.

Size State Bag limiter

  • rateLimiter_stateBagSize_rate default value is 131,072 - the size limit of the packets per 1 second
  • rateLimiter_stateBagSize_burst default value is 262,144 - the size burst limit of the packets per 1 second

If a client is detected to be sending too large packets then the server will automatically drop them to prevent them from overloading the network thread and to prevent the possibility of memory exhaustion.

For reference these are the values we run on our server

# the client rarely sets state bags so this value should be extremely low
set rateLimiter_stateBag_rate 20
set rateLimiter_stateBag_burst 30

# setting this to 0 will cause a server assert
set rateLimiter_stateBagFlood_rate 1
set rateLimiter_stateBagFlood_burst 1

# clients should never sync large state to the server
# set rateLimiter_stateBagSize_rate 16000
# set rateLimiter_stateBagSize_burst 18000

@FabianTerhorst FabianTerhorst self-assigned this Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Needs a preliminary assessment to determine the urgency and required action
Projects
None yet
Development

No branches or pull requests

5 participants