Skip to content

Add WebSocket rate limits and payload size limits (#338) - #405

Merged
dzekojohn4 merged 4 commits into
UnityChainxx:mainfrom
eulami:feat/rate-limit-multiplayer-notifications
Aug 31, 2026
Merged

Add WebSocket rate limits and payload size limits (#338)#405
dzekojohn4 merged 4 commits into
UnityChainxx:mainfrom
eulami:feat/rate-limit-multiplayer-notifications

Conversation

@eulami

@eulami eulami commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Closes #338

eulami and others added 3 commits August 31, 2026 08:12
… oversized payloads

Add per-user rate limiting and payload size validation to the multiplayer queue
and in-app notifications modules to prevent abuse.

- Introduce RateLimitGuard (in-memory sliding-window, per-IP) and @ratelimit
  decorator for configurable per-route throttling (429 with retryAfter header).
- Apply rate limits: join 5/min, matchmaking 2/min, reads 30/min,
  notification create 10/min, system broadcast 5/min.
- Enforce max field lengths: notification title 200 chars, message 2000 chars,
  username 100 chars, gameMode 50 chars.
- Cap array sizes: opponents lists ≤10, batch mark-read ≤100.

Closes UnityChainxx#338

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
… notifications

Implement WebSocket gateways for the multiplayer queue and in-app
notifications channels with per-socket rate limiting and payload size
validation, addressing the core ask of UnityChainxx#338.

- MultiplayerGateway (/multiplayer namespace):
  joinQueue 5/min, leaveQueue 10/min, getQueueStatus 30/min
- NotificationsGateway (/notifications namespace):
  subscribe 5/min, sendNotification 10/min, broadcastNotification 3/min,
  getUnreadCount 30/min
- WsRateLimitGuard: in-memory sliding-window throttler keyed by socket userId
  with periodic cleanup (5 min)
- @WsRateLimit decorator for per-handler limits
- All handlers validate payload size (8 KB max) and field lengths inline
  before touching the service layer

Closes UnityChainxx#338

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@eulami Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@dzekojohn4 dzekojohn4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, merging in.

@dzekojohn4
dzekojohn4 merged commit ef7e240 into UnityChainxx:main Aug 31, 2026
8 of 11 checks passed
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.

[P1][backend] Add WebSocket rate limits and payload size limits

2 participants