Rate limiting Subscriptions

Although it seems very easy to implement, DDP Rate Limiting for Meteor Subscriptions seems to be not working.
I have the following code snippet in “/imports/api/server” folder.

Meteor.publish('todos.public', function todosPublic () {
    return Todos.find(
        { },
        { fields: Todos.fieldsExposed }

I provide a rate limiter in “/imports/startup/server” folder as follows;

const todosPublication = {
    type: 'subscription',
    name: 'todos.public',
DDPRateLimiter.addRule(todosPublication, 1, 100);

And I test the limiter in a React component in the following code;

componentWillMount () {
        for (let i = 0; i < 25000; i++) {

The result is I don’t get any error, which means the limiter does not work.

Moreover, I don’t see any rate limiting for Subscriptions in Meteor React Tutorial code, either. But, they have for Methods.

Any idea?

1 Like

That seems to be a feature, not a bug. If you send the same arguments, the publication will not be re-subscribed to. Pass a random argument to the sub in your test and see if that works.


you publication is using this Meteor.publish('todos.public'

but your subscription is Meteor.subscribe('reminders.public');… i haven’t used DDP limiter but saw your code difference =)

1 Like

It was a copy-paste error. Sorry. In the real code it is correct. I installed Meteor’s Chrome Tool to monitor the DDP traffic and there I see the “unsub” messages from the server. The server responses with unsub due the rate limiter. What is confusing for me is, why I did not get any error log either on the server or client sides as I got these error for rate limiting Meteor Methods.