简体   繁体   English

Watson Assistant 日志错误“超出速率限制”

[英]Watson Assistant Log Error "Rate limit exceeded"

I need your help in getting Watson Assistant Logs.我需要你的帮助来获取 Watson Assistant 日志。 I am getting an error “Rate limit exceeded”.我收到错误“超出速率限制”。 According to API docs, we can specify cursor in param.根据 API 文档,我们可以在 param 中指定游标。 When cursor is specified we can make 120 requests / min.当指定游标时,我们可以发出 120 个请求/分钟。 If cursor is not specified then we can make 40 requests / 30min only.如果未指定游标,那么我们只能发出 40 个请求/30 分钟。 I have passed cursor attribute in “param” object as empty string when it first initiates and then I have updated the cursor value to next_cursor value which was returned by Watson (pagination attribute as a token).当“param”对象第一次启动时,我已将其作为空字符串传递给“param”对象中的游标属性,然后我将游标值更新为由 Watson 返回的 next_cursor 值(分页属性作为标记)。 However, still its making 40 requests and connection gets closed for 30 min.但是,它仍然发出 40 个请求,并且连接关闭了 30 分钟。 Could you please tell me what I am doing wrong?你能告诉我我做错了什么吗? I am able to retrieve 40 logs in text file.我能够在文本文件中检索 40 个日志。 I am using Node JS.我正在使用节点 JS。 I am looking forward to hearing from you.我期待着您的回音。

Below is the small sample function which I have created:下面是我创建的小示例函数:

const getLogs = () => {
           const params = {
             workspace_id: '50f6598a-a369-45df-9cfb-20bdfe617066',
             cursor: ""
           }
           service.listLogs(params)
           .then(res => {
             if(res.pagination.next_cursor) {
               fs.writeFile("temp.txt", JSON.stringify(res, null, 2), err => {
                 if (err) console.log(err);
                 console.log("Successfully Written to File.");
               });
               params.cursor = res.pagination.next_cursor;
               getLogs()
             } else {
               console.log('no more logs')
             }
           })
           .catch(err => console.log(JSON.stringify(err, null, 2)));
         }
         getLogs();

{
  "name": "Too Many Requests",
  "code": 429,
  "message": "Rate limit exceeded",
  "body": "{\"error\":\"Rate limit exceeded\",\"code\":429}",
  "headers": {
    "x-backside-transport": "FAIL FAIL",
    "content-type": "application/json; charset=utf-8",
    "access-control-allow-origin": "*",
    "access-control-allow-methods": "GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS",
    "access-control-allow-headers": "Content-Type, Content-Length, Authorization, X-Watson-Authorization-Token, X-WDC-PL-OPT-OUT, X-Watson-UserInfo, X-Watson-Learning-Opt-Out, X-Watson-Metadata",
    "access-control-max-age": "3600",
    "content-security-policy": "default-src 'none'",
    "x-dns-prefetch-control": "off",
    "x-frame-options": "SAMEORIGIN",
    "strict-transport-security": "max-age=31536000;",
    "x-download-options": "noopen",
    "x-content-type-options": "nosniff",
    "x-xss-protection": "1; mode=block",
    "x-ratelimit-limit": "40",
    "x-ratelimit-reset": "1559060571",
    "x-ratelimit-remaining": "0",
    "retry-after": "1143.36",
    "x-global-transaction-id": "7ecac92c5ced5be3440b2991",
    "x-dp-watson-tran-id": "gateway01-1141582225",
    "x-dp-transit-id": "gateway01-1141582225",
    "content-length": "42",
    "x-edgeconnect-midmile-rtt": "256",
    "x-edgeconnect-origin-mex-latency": "210",
    "date": "Tue, 28 May 2019 16:03:47 GMT",
    "connection": "close"
  }
}

I think this may be recursion related and that params.cursor is set to "" at the start of each recursion.我认为这可能与递归有关,并且 params.cursor 在每次递归开始时都设置为 ""。 What you need to do is to combine recursion with closure.您需要做的是将递归与闭包结合起来。 So your code will look something like:所以你的代码看起来像:

 const getLogs = () => {
   const params = {
        workspace_id: '50f6598a-a369-45df-9cfb-20bdfe617066',
        cursor: ""
    }
   function doGetLogs() {
     service.listLogs(params)
     .then(res => {
        if(res.pagination.next_cursor) {
                ...
                params.cursor = res.pagination.next_cursor;
                doGetLogs()
              } 
              ...
            })
           ...
   }
   return doGetLogs();
 }

 getLogs();

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

相关问题 Watson Assistant 上下文未更新 - Watson Assistant context is not updated Watson 助手的自定义 UI - Custom UI for watson assistant Google SDK返回403“超出用户速率限制” - Google SDK returns 403 `User Rate Limit Exceeded` 将动态内容发送给Watson Assistant - Sending dynamic content to watson assistant 在 Fastify 中,如何在超过速率限制配额后禁止用户 60 秒。 ( fastify-rate-limit ) - How to ban a user for 60 seconds after he exceeded rate limit quota, in Fastify. ( fastify-rate-limit ) PayPal REST API-达到速率限制错误 - PayPal REST API - RATE LIMIT REACHED error 证书链中的自签名证书将node.js SDK用于Watson Assistant时出错 - Self signed certificate in certificate chain Error while using node.js SDK for watson assistant 设置权限'sendNotificationEmails'的正确语法是什么:'false'以避免“消息”:“超出速率限制。用户消息: - What Is it the correct syntax to set permission 'sendNotificationEmails': 'false' to avoid “message” : "Rate limit exceeded. User message: 如何将客户令牌传递到 IBM Watson Assistant - How to passg customer token into IBM Watson Assistant Watson Assistant 在嵌套节点内获取消息 - Watson Assistant get message inside nested node
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM