0

I need to send more than one message to a single topic in just one second.

I have three Android devices and I'm trying to send multiple downstream messages to a topic (the three devices are subscribed to) in a short period of time (one second). Our server does ACK for the three of them.

In that moment, we send two messages to the topic, but one of them returns NACK with an error message of TOPICS_MESSAGE_RATE_EXCEEDED.

And now, we retry to resend the message again, if time_to_live doesn't expire first. In our case, that message tried re-sending again when the user clicks on it again. Is this the correct behavior?

Did anyone have this problem before? How is it solved?

AL.
  • 36,815
  • 10
  • 142
  • 281
dzivi
  • 33
  • 1
  • 11
  • 2
    I'd assume by paying money. – Kayaman Oct 25 '16 at 13:10
  • If is that correct, where can I find a description of this problem? – dzivi Oct 25 '16 at 13:14
  • I'd assume in the documentation where they say "if you want to use this service for real workloads, you need to pay money". I'm just assuming. It sounds like you're using a free version of something and it only allows you such pitiful transfer rates. – Kayaman Oct 25 '16 at 13:17
  • Ok. Thank you. I'll check that. – dzivi Oct 25 '16 at 13:19
  • 1
    FCM service is free. Regardless of which plan you are using. – AL. Oct 25 '16 at 13:42
  • 1
    I'm voting to close this question as off-topic because it is about the service level agreement of an external service – rene Oct 25 '16 at 20:26
  • 1
    I think this is a valid question. If anything, it can be considered as low quality since minimal details were provided. However, the details itself (just the scenario) was sufficient, enough to provide an idea to what's happening. – AL. Oct 25 '16 at 21:21
  • I am new here and I learn how to write here. This is my scenario: Three android devices send message on one topic at same time(same second). Our server do ACK for three of them and try to do downstream to topic. In that moment we send two message to topic and one of them return NACK with error message TOPICS_MESSAGE_RATE_EXCEEDED. And now that message try to resend again if time to live no expires first. In our case that message try resend again like android user click on again. Is it correct behavior? Can you tell as little closer to the procedure in our case? – dzivi Oct 25 '16 at 22:02

1 Answers1

3

This is the expected behavior for GCM/FCM. Sending multiple messages to a topic in a short amount of time will cause this error.

I think this serves as a safety net for GCM/FCM against flooding and is also about handling the traffic. Just imagine if you have a 1000 subscribers then you send multiple multiple messages in less than a second to that topic.

You should implement a delay (about 5-10 seconds) for each message you send to the topic.

Also mentioned by @Eran's answer here (which is based from the docs):

Topics Message Rate Exceeded The rate of messages to subscribers to a particular topic is too high. Reduce the number of messages sent for this topic, and do not immediately retry sending.

Community
  • 1
  • 1
AL.
  • 36,815
  • 10
  • 142
  • 281
  • Thank you for your time. This is good. I have read about exponential backoff. Is that good idea? – dzivi Oct 25 '16 at 19:36
  • @12345 Exponential backoff is normally used as a *fail safe*. You can use it if you like. But for your scenario, since the TOPICS_MESSAGE_RATE_EXCEEDED is already expected, you should simply implement delays when sending the messages to avoid it totally – AL. Oct 25 '16 at 21:17
  • @12345 Just wanted to check in on you. Are you still encountering the error even after implementing delays to your requests? I've noticed that you edited your post where you're trying to verify a behavior. I'm having difficulty in understanding it. Can you expound more? – AL. Nov 08 '16 at 07:16
  • 1
    We are receiving this error randomly. Even after not sending notifications for about 5 minutes we get it. For the same topic a minut later it suddently works, but then it might fail again later on. There must be something wrong in the backend of firebase, because the messaging/message-rate-exceeded and quota-rate-exceeded errors are randomly popping up – Gillis Haasnoot Mar 18 '19 at 21:03