jlcvp / fcm-node

A Node.JS simple interface to Google's Firebase Cloud Messaging (FCM) for Android & iOS & Web Notification and data push
MIT License
125 stars 46 forks source link

the error code:TopicsMessageRateExceeded response #6

Closed kungteli closed 7 years ago

kungteli commented 7 years ago

Recently got an error response “TOPICS_MESSAGE_RATE_EXCEEDED” which I never got in the past. It happened from 2016/8/25 until now. My node server is simply sending 10 messages to my client with “topics/global” in loop. It has been running well since year ago. But recently it became sending error but only succeed for 2 messages in 10 messages. image

jlcvp commented 7 years ago

@kungteli

  1. can you inform the dependencies you're using in your package.json?
  2. are the server behind any proxy?
kungteli commented 7 years ago

Hello, Attached below consloe.log from script for your reference. you should be able to find out the JSON file structure.i didnt use an Package.json file. i just simply select the data from sqlite database then covert it to json format . I also attached my script as following.

by the way, I am using my laptop as my server for sending message. for sure ,there is no proxy. thanks for your time on this.

console log from script:

url:/sendJourney?Theme=%E7%B4%90%E8%A5%BF%E8%98%AD%E9%9C%B2%E7%87%9F%E8%BB%8A&_=1474670440963 紐西蘭露營車:{"to":"/topics/global","data":{"DataSet":"Journey","Journey":{"RegisterId":"SystemGen","Theme":"紐西蘭露營車","ThemePhoto":" http://mw2.google.com/mw-panoramio/photos/medium/4549663.jpg ","Remark":""},"Stopover":{"TheDate":"2016/10/04","TheTime":"17:46","PlaceId":"ChIJAe3FY0gvMm0RRZl5hIbvAAU"}}} 紐西蘭露營車:{"to":"/topics/global","data":{"DataSet":"Journey","Journey":{"RegisterId":"SystemGen","Theme":"紐西蘭露營車","ThemePhoto":" http://mw2.google.com/mw-panoramio/photos/medium/4549663.jpg ","Remark":""},"Stopover":{"TheDate":"2016/10/06","TheTime":"17:48","PlaceId":"ChIJc54cIHbNK20Ruhvd8mctSzs"}}} 紐西蘭露營車:{"to":"/topics/global","data":{"DataSet":"Journey","Journey":{"RegisterId":"SystemGen","Theme":"紐西蘭露營車","ThemePhoto":" http://mw2.google.com/mw-panoramio/photos/medium/4549663.jpg ","Remark":""},"Stopover":{"TheDate":"2016/10/05","TheTime":"17:46","PlaceId":"ChIJUxDVTdk_L20RoHJ5hIbvAAU"}}} 紐西蘭露營車:{"to":"/topics/global","data":{"DataSet":"Journey","Journey":{"RegisterId":"SystemGen","Theme":"紐西蘭露營車","ThemePhoto":" http://mw2.google.com/mw-panoramio/photos/medium/4549663.jpg ","Remark":""},"Stopover":{"TheDate":"2016/10/08","TheTime":"17:50","PlaceId":"ChIJG1XEcHwY1akR8Fx5hIbvAAU"}}} 紐西蘭露營車:{"to":"/topics/global","data":{"DataSet":"Journey","Journey":{"RegisterId":"SystemGen","Theme":"紐西蘭露營車","ThemePhoto":" http://mw2.google.com/mw-panoramio/photos/medium/4549663.jpg ","Remark":""},"Stopover":{"TheDate":"2016/10/07","TheTime":"17:49","PlaceId":"ChIJoy1uvEZf1akRECFlq4bvACo"}}} 紐西蘭露營車:{"to":"/topics/global","data":{"DataSet":"Journey","Journey":{"RegisterId":"SystemGen","Theme":"紐西蘭露營車","ThemePhoto":" http://mw2.google.com/mw-panoramio/photos/medium/4549663.jpg ","Remark":""},"Stopover":{"TheDate":"2016/10/10","TheTime":"17:52","PlaceId":"ChIJa15mlSBt1KkRULR5hIbvAAU"}}} 紐西蘭露營車:{"to":"/topics/global","data":{"DataSet":"Journey","Journey":{"RegisterId":"SystemGen","Theme":"紐西蘭露營車","ThemePhoto":" http://mw2.google.com/mw-panoramio/photos/medium/4549663.jpg ","Remark":""},"Stopover":{"TheDate":"2016/10/09","TheTime":"17:51","PlaceId":"ChIJX96o1_Ed1akRAKZ5hIbvAAU"}}} 紐西蘭露營車:{"to":"/topics/global","data":{"DataSet":"Journey","Journey":{"RegisterId":"SystemGen","Theme":"紐西蘭露營車","ThemePhoto":" http://mw2.google.com/mw-panoramio/photos/medium/4549663.jpg ","Remark":""},"Stopover":{"TheDate":"2016/10/13","TheTime":"17:55","PlaceId":"ChIJyzN1lfTLK20RZeiD_UXKWSQ"}}} 紐西蘭露營車:{"to":"/topics/global","data":{"DataSet":"Journey","Journey":{"RegisterId":"SystemGen","Theme":"紐西蘭露營車","ThemePhoto":" http://mw2.google.com/mw-panoramio/photos/medium/4549663.jpg ","Remark":""},"Stopover":{"TheDate":"2016/10/14","TheTime":"17:55","PlaceId":"ChIJt9T3rAmZK20RwNhkq4bvACo"}}} 紐西蘭露營車:{"to":"/topics/global","data":{"DataSet":"Journey","Journey":{"RegisterId":"SystemGen","Theme":"紐西蘭露營車","ThemePhoto":" http://mw2.google.com/mw-panoramio/photos/medium/4549663.jpg ","Remark":""},"Stopover":{"TheDate":"2016/10/14","TheTime":"17:54","PlaceId":"ChIJPVFfD-DkK6gRQZl5hIbvAAU"}}} 紐西蘭露營車:{"to":"/topics/global","data":{"DataSet":"Journey","Journey":{"RegisterId":"SystemGen","Theme":"紐西蘭露營車","ThemePhoto":" http://mw2.google.com/mw-panoramio/photos/medium/4549663.jpg ","Remark":""},"Stopover":{"TheDate":"2016/10/11","TheTime":"17:53","PlaceId":"ChIJ4UlLuk3g1akRAN5kq4bvACo"}}} {"error":"TOPICS_MESSAGE_RATE_EXCEEDED"} {"error":"TOPICS_MESSAGE_RATE_EXCEEDED"} {"error":"TOPICS_MESSAGE_RATE_EXCEEDED"} {"error":"TOPICS_MESSAGE_RATE_EXCEEDED"} {"error":"TOPICS_MESSAGE_RATE_EXCEEDED"} {"error":"TOPICS_MESSAGE_RATE_EXCEEDED"} {"error":"TOPICS_MESSAGE_RATE_EXCEEDED"} {"error":"TOPICS_MESSAGE_RATE_EXCEEDED"} {"message_id":7800592870254005364} {"message_id":8480088838345689645} {"error":"TOPICS_MESSAGE_RATE_EXCEEDED"}

my javascript:

function SubmitJourney(Theme){ var JourneySql="SELECT * FROM Journey Where Theme = '" + Theme +"'"; var StopoverSql= "SELECT TheDate,TheTime,PlaceId FROM Stopover where Stopover.Theme='"+ Theme + "'"; // console.log("StopoverSQL:"+StopoverSql); var ctlDate =""; var Days = 0; db.each(JourneySql, function(err, row) { db.each(StopoverSql, function(err, rows) { var message = { to: '/topics/global', // notification: { // title: row.Theme, // body: row.Remarks, // icon : "ic_tripassist" // }, data: { //you can send only notification or only data(or include both) DataSet: 'Journey', Journey:row, Stopover:rows } };

console.log(Theme+":"+JSON.stringify(message)); fcm.send(message, function (err, response) { if(err) console.error(err); else console.log(response); }); // wait(5000); }); }); return;

}

2016-09-23 21:16 GMT+08:00 João Leonardo Pereira notifications@github.com:

@kungteli https://github.com/kungteli

  1. can you inform the dependencies you're using in your package.json?
  2. are the server behind any proxy?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Saber-Tecnologias/fcm-node/issues/6#issuecomment-249189866, or mute the thread https://github.com/notifications/unsubscribe-auth/AP3l4lQ-p-aLgqCnsJykOZr_mUXRLmVDks5qs9FEgaJpZM4KEfGR .

jlcvp commented 7 years ago

My best guess is that your IP range or API KEY has been flagged by the Firebase/Google servers as a possible source of attacks/spam. The Firebase's documentation doesn't tell explicitly how this topic messsages rate limit is calculated, so it's just a guess. My advice is to try to collapse all the messages that you send in a loop in only one data object to send through only 1 message (maybe a jsonArray to be treated inside your app could be a good option).

kungteli commented 7 years ago

Thanks anyway, i also tried to create another server key under a different project. The result is same. Now i plan to go with other alternative for resolution. Thanks for your time and sincely appreciate .

2016/9/28 上午12:51,"João Leonardo Pereira" notifications@github.com寫道:

My best guess is that your IP range or API KEY has been flagged by the Firebase/Google servers as a possible source of attacks/spam. The Firebase's documentation doesn't tell explicitly how this topic messsages rate limit is calculated, so it's just a guess. My advice is to try to collapse all the messages that you send in a loop in only one data object to send through only 1 message (maybe a jsonArray to be treated inside your app could be a good option).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Saber-Tecnologias/fcm-node/issues/6#issuecomment-249925956, or mute the thread https://github.com/notifications/unsubscribe-auth/AP3l4lnRwzGQBdU6flb4wKuGwtr-OLAhks5quUmbgaJpZM4KEfGR .