TykTechnologies / tyk

Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols
Other
9.68k stars 1.08k forks source link

[WIP] [TT-13206] Add support for websocket rate limiting #6630

Open buger opened 2 weeks ago

buger commented 2 weeks ago

Should be enabled with enable_websockets_rate_limiting

This is fully native rate and quota limiting, on per INCOMING message from the user.

Does not depend on Tyk Streams.

You can set rate limits via keys/policies as usual. Will work with path based rate limiting as well.

It also returns nice compilant error and reason message in case of rate limit:

(base) % wscat -c http://127.0.0.1:8282/websocket-proxy/\?key\=eyJvcmciOiI2NTE3MGY4MWVhOWJmNjA0YmI0NzRjMDIiLCJpZCI6ImI0MDVlNmQ1NjVjNTQ3MjRhMjczMDRkMzcyNWFhODg1IiwiaCI6Im11cm11cjY0In0=
Connected (press CTRL+C to quit)
< Request served by 1781505b56ee58
> test
< test
> test
< test
> test
< test
> test
< test
> test
Disconnected (code: 4000, reason: "rate limit exceeded")

Related Issue

Motivation and Context

How This Has Been Tested

Screenshots (if appropriate)

Types of changes

Checklist