简体   繁体   English

RestException [错误]:请求过多状态:429,代码:20429,

[英]RestException [Error]: Too many requests status: 429, code: 20429,

helper function below is my helper function which do two things.下面的助手 function 是我的助手 function,它做了两件事。 1.generateotp function will send otp to mobile from req.body(here i pass two parametr mobile number and channel. channel is mode of sending otp means sms or otp here it is sms) 2.secon function will verify the otp which user recived. 1.generateotp function 将从 req.body 发送 otp 到手机(这里我传递了两个参数手机号码和频道。频道是发送 otp 表示短信或 otp 这里是短信的模式) 2.secon ZC1C425268E68385D1AB5074C17A94F1Z 将验证用户接收的otp . here also we take 2 parameter mobile number and otp这里我们也采用 2 参数手机号码和 otp

var db = require('../config/connection');
const config=  require('../config/config');
const collection = require('../config/connection');
const client = require("twilio")(config.accountSID,config.authToken)
module.exports={ 
     generateOtp:(userNumber,channel) => {
        client
        .verify
        .services(config.serviceID)
        .verifications
        .create({
          to:`+91${userNumber}`,
          channel:channel
        })
        .then((data) => {
            console.log(data)
            // return callback(null, 'success');
        })
        .catch((error) => {
            console.log(error);
        });
     },
     
     verifyOtp:(userNumber,userOtp) => {
         client
         .verify
         .services(config.serviceID)
         .verificationChecks
         .create({
            to:`+91$${userNumber}`,
            code:userOtp

         })
         .then((data) => {
             console.log(data);
         })
         .catch((error) => {
             console.llog(error);
         })
     }
}

Route路线

/Generate Otp
 router.post('/signup',(req,res) => { 
   const {userNumber, channel} = req.body;
    userhelper.generateOtp(userNumber,channel)
    return res.redirect('/verify');
 });
 //Verify Otp
 router.post('/verify',(req,res) => {
   const {userNumber,userOtp} = req.body;
   console.log(req.body);
  // userhelper.verifyOtp(userNumber,userOtp)
 })

I am using twilio verify api for mobile number verification the above code worked perfectly till yesterday now when is test code i am getting an error.我正在使用 twilio 验证 api 进行手机号码验证,上面的代码工作完美,直到昨天现在是测试代码我收到错误。

RestException [Error]: Too many requests
    at success (C:\Users\Alfas Ahmed\Desktop\whatsapp-ecom\node_modules\twilio\lib\base\Version.js:135:15)
    at Promise_then_fulfilled (C:\Users\Alfas Ahmed\Desktop\whatsapp-ecom\node_modules\q\q.js:766:44)
    at Promise_done_fulfilled (C:\Users\Alfas Ahmed\Desktop\whatsapp-ecom\node_modules\q\q.js:835:31)
    at Fulfilled_dispatch [as dispatch] (C:\Users\Alfas Ahmed\Desktop\whatsapp-ecom\node_modules\q\q.js:1229:9)
    at Pending_become_eachMessage_task (C:\Users\Alfas Ahmed\Desktop\whatsapp-ecom\node_modules\q\q.js:1369:30)
    at RawTask.call (C:\Users\Alfas Ahmed\Desktop\whatsapp-ecom\node_modules\asap\asap.js:40:19)
    at flush (C:\Users\Alfas Ahmed\Desktop\whatsapp-ecom\node_modules\asap\raw.js:50:29)
    at processTicksAndRejections (internal/process/task_queues.js:75:11) {
  status: 429,
  code: 20429,
  moreInfo: 'https://www.twilio.com/docs/errors/20429',
  details: undefined
}

How to test Twilio Verify without getting rate limited https://www.twilio.com/blog/test-verify-no-rate-limits如何测试Twilio验证而不限制速率

Above what happened is, in development time I just tested many time with same mobile number.上面发生的事情是,在开发时我只是用同一个手机号码测试了很多次。 Twilio just blocked service. Twilio 刚刚阻止了服务。 So I just created new Service id, now the code working perfectly fine.所以我刚刚创建了新的服务 ID,现在代码工作得很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM