首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >负载测试Bot建造者bot

负载测试Bot建造者bot
EN

Stack Overflow用户
提问于 2017-12-02 07:35:28
回答 3查看 1.1K关注 0票数 1

更新

使用仿真器作为channelId并对SDK3.13.1进行更新对我很有帮助。

  • 应用程序ID: 8c082f92-fb38-4841-a29f-339eb315f7aa
  • SDK平台: Node.js
  • SDK版本: 3.13.1
  • 活跃频道: Facebook
  • 部署环境: ngrok

问题描述

我尝试了此链接中提到的步骤。这有两部分。一种是创建令牌,第二种是向机器人发送消息。POSTMAN请求导致500个内部服务器错误和错误: ChatConnector:接收无效签名密钥或代码中的OpenId元数据文档。

代码示例

  1. 创建令牌 curl -X POST https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token -H 'cache-control:无缓存‘-H’内容-类型:application/x form-urlencoded‘-H’邮递员-令牌: 792660ab-b1aa-0cbd-edab-9b3847c170d5‘-d
  2. 发消息 curl -X -X https://1c36f336.ngrok.io/api/messages -H‘授权:无记名https://1c36f336.ngrok.io/api/messages -H 'cache-control: no-cache’-H‘内容-类型: application/json’-H‘邮递员-令牌:3a74ce00-2 da7 -d 674-5e4c-083f54ed30ff’-d '{ "type":"message","id":“$cAAGEkG8Mm1mOEBe-lgBvsWZbQUc”,"channelId“:”测试“,“会话”:{ "id":"100023023852067-526013297749070"}," from ":{ "id":"100023023852067“},”收件人“:{ "id":"526013297749070”},"serviceUrl":"https://1c36f336.ngrok.io",“text:"Hi message from postman!”

复制步骤

  1. 使用上面提到的两个curl请求。这应该会导致上述问题。

预期行为

邮递员请求应导致202接受和bot接收消息。我是错过了什么,还是在这个过程中出现了什么问题?我在负载测试中看到了一些 问题,但它们都没有帮助。

实际结果

POSTMAN请求导致500个内部服务器错误和错误: ChatConnector:接收无效签名密钥或代码中的OpenId元数据文档。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2017-12-09 00:23:41

后来我才能让这个工作起来:

1)使用botbuilder向bot添加自定义状态客户端。

2)公开消息接收器,用于接收bot响应

3)将channelId更改为“模拟器”(显然node不处理‘测试’通道)

代码语言:javascript
复制
curl -X POST  https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token -H "content-type: application/x-www-form-urlencoded" -d "grant_type=client_credentials&client_id=MyMicrosoftAppId&client_secret=MyMicrosoftAppPassword&scope=MyMicrosoftAppId%2F.default"

curl -X POST https://e84a2f49.ngrok.io/api/messages -H "authorization: Bearer TokenFromPreviousCall" -d "{ \"type\": \"message\", \"id\": \"mid.$cAAGEkG8MNm1mOEBe-lgBvsWZbQUc\", \"channelId\" : \"emulator\",  \"conversation\": { \"id\": \"100023023852067-526013297749070\"}, \"from\": { \"id\": \"100023023852067\" }, \"recipient\": { \"id\": \"526013297749070\" },  \"serviceUrl\": \"https://e84a2f49.ngrok.io\", \"text\": \"Hi message from postman !!!\" }"

这是应用程序,供参考:

代码语言:javascript
复制
var restify = require('restify');
var builder = require('botbuilder');
var azure = require('botbuilder-azure');

var sqlConfig = {
    userName: 'SqlServerUserId',
    password: 'SqlServerPassword',
    server: 'mySqlServer.net',
    enforceTable: true, 
    options: {
        database: 'BotDatabaseName',
        table: 'BotDataTableName',
        encrypt: true,
        rowCollectionOnRequestCompletion: true
    }
}

var sqlClient = new azure.AzureSqlClient(sqlConfig);
var sqlStorage = new azure.AzureBotStorage({ gzipData: false }, sqlClient);

var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3980, function () {
    console.log('%s listening to %s', server.name, server.url);
});

var connector = new builder.ChatConnector({
    appId: "MyAppId",
    appPassword: "MyAppPassword" 
});

server.post('/api/messages', connector.listen());

var bot = new builder.UniversalBot(connector, function (session) {
    session.send("You said: %s", session.message.text);
}).set('storage', sqlStorage);;

//message sink 
server.post("/v3/conversations/:conversationId/activities/:activityId", function(Request, Response, next) {
    next();
});
票数 2
EN

Stack Overflow用户

发布于 2017-12-06 09:35:57

不确定这是否有用,但如果您在每个负载测试请求中使用相同的"fromId“,则可能与此相关。

以前,我遇到过一个类似的问题,要求我在每个请求中使用唯一的"fromId“,否则一系列快速连续的请求就会开始失败。

我在github上提出了这个问题,虽然它说“离线跟踪”和“bot代码的问题”,但实际上是由于在每个请求中使用了相同的"fromId“。

问题就在这里:https://github.com/Microsoft/BotBuilder/issues/1176

票数 1
EN

Stack Overflow用户

发布于 2018-08-16 17:29:29

在我添加extended字段之后,我得到了相同的错误。不确定这有什么关系,但是替换

代码语言:javascript
复制
server.use(bodyParser.urlencoded({ extended: true }));

至:

代码语言:javascript
复制
server.use(bodyParser.urlencoded());

解决了这个问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47605699

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档