Run code before hub dispatcher #58650
Unanswered
SylvainGantois
asked this question in
Q&A
Replies: 2 comments
-
Have you tried overriding the default SignalR services.AddSingleton(typeof(HubDispatcher<YourHubType>), typeof(CustomHubDispatcher<YourHubType>));
services.AddSingleton<IRateLimiter, YourRateLimiterImplementation>(); |
Beta Was this translation helpful? Give feedback.
0 replies
-
Unfortunately, it looks like we cannot use the HubDispatcher class anymore. Feels like a rabbit hole if we have to reimplement a bunch of classes. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
We have a rate limiter that works for both HTTP requests and SignalR (we use exclusively web sockets for SignalR).
The SignalR rate limiting currently works as a hub filter, however, this will not take into account calls made to an inexisting hub method.

The default hub dispatcher displays a debug log and that's the end of the request:
We have rate limits per user or SignalR connection and those calls should be taken into account (if a bad client makes a lot of invalid calls, we want to be aware of it, and maybe disable the user or block the IP, etc...).
Is there a way to create a custom hub dispatcher that would do some work before calling the default one, or a way to hook something else before the dispatcher?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions