更新
使用仿真器作为channelId并对SDK3.13.1进行更新对我很有帮助。
问题描述
我尝试了此链接中提到的步骤。这有两部分。一种是创建令牌,第二种是向机器人发送消息。POSTMAN请求导致500个内部服务器错误和错误: ChatConnector:接收无效签名密钥或代码中的OpenId元数据文档。
代码示例
复制步骤
预期行为
邮递员请求应导致202接受和bot接收消息。我是错过了什么,还是在这个过程中出现了什么问题?我在负载测试中看到了一些 问题,但它们都没有帮助。
实际结果
POSTMAN请求导致500个内部服务器错误和错误: ChatConnector:接收无效签名密钥或代码中的OpenId元数据文档。
发布于 2017-12-09 00:23:41
后来我才能让这个工作起来:
1)使用botbuilder向bot添加自定义状态客户端。
2)公开消息接收器,用于接收bot响应
3)将channelId更改为“模拟器”(显然node不处理‘测试’通道)
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 !!!\" }"这是应用程序,供参考:
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();
});发布于 2017-12-06 09:35:57
不确定这是否有用,但如果您在每个负载测试请求中使用相同的"fromId“,则可能与此相关。
以前,我遇到过一个类似的问题,要求我在每个请求中使用唯一的"fromId“,否则一系列快速连续的请求就会开始失败。
我在github上提出了这个问题,虽然它说“离线跟踪”和“bot代码的问题”,但实际上是由于在每个请求中使用了相同的"fromId“。
发布于 2018-08-16 17:29:29
在我添加extended字段之后,我得到了相同的错误。不确定这有什么关系,但是替换
server.use(bodyParser.urlencoded({ extended: true }));至:
server.use(bodyParser.urlencoded());解决了这个问题。
https://stackoverflow.com/questions/47605699
复制相似问题