Bot仿真器错误:POST 400 directline.postActivity

时间:2019-06-10 15:49:20

标签: azure botframework

我正在尝试在Bot仿真器中运行默认的EchoBot,在配置了端点,AppID和App密码之后,我收到了POST 400 directline.postActivity错误。

我正在运行Bot Emulator Framework v4.4.1和Microsoft提供的C#v4.4.4 EchoBot示例。当我在Visual Studio中构建项目时,它输出到本地主机上的端口3978。在仿真器中输入端点,ID和密码后,它开始连接。但是,该漫游器不会响应任何输入的文本。这是模拟器的日志:

[11:05:36]Emulator listening on http://localhost:50550
[11:05:36]ngrok not configured (only needed when connecting to remotely     hosted bots)
[11:05:36]Connecting to bots hosted remotely
[11:05:36]Edit ngrok settings
[11:05:37]
[11:05:37]POSTdirectline.conversationUpdate
[11:05:37]
[11:05:37]POSTdirectline.conversationUpdate
[11:05:37]POST200directline.startConversation
[11:05:40]-> messagehell0
[11:05:40]POST400directline.postActivity
[11:05:43]-> messagefdal
[11:05:43]POST400directline.postActivity

JSON Inspector for startConversation: 
{
  "conversationId": "33eb05b0-8b91-11e9-be8e-6726cb4f7972|livechat",
  "expires_in": 2147483647,
  "streamUrl": "",
  "token": "http://localhost:3978"
}

JSON Inspector for first message:
{
  "channelData": {
    "clientActivityID": "15601791407590.8nf8jwqjc2v"
  },
  "channelId": "emulator",
  "conversation": {
    "id": "33eb05b0-8b91-11e9-be8e-6726cb4f7972|livechat"
   },
  "entities": [
    {
      "requiresBotState": true,
      "supportsListening": true,
      "supportsTts": true,
      "type": "ClientCapabilities"
    }
  ],
  "from": {
    "id": "4866b179-bf7b-460e-8903-bda849861d88",
    "name": "User",
    "role": "user"
  },
  "id": "363766b0-8b91-11e9-be8e-6726cb4f7972",
  "localTimestamp": "2019-06-10T11:05:40-04:00",
  "locale": "en-US",
  "recipient": {
    "id": "33ea6970-8b91-11e9-ab08-9bfc690fe455",
    "name": "Bot",
    "role": "bot"
  },
  "serviceUrl": "http://localhost:50550",
  "text": "hell0",
  "textFormat": "plain",
  "timestamp": "2019-06-10T15:05:40.763Z",
  "type": "message"
}

JSON Inspector for first response:
{
  "channelData": {
    "clientActivityID": "15601791407590.8nf8jwqjc2v"
  },
  "channelId": "webchat",
  "entities": [
    {
      "requiresBotState": true,
      "supportsListening": true,
      "supportsTts": true,
      "type": "ClientCapabilities"
    }
  ],
  "from": {
    "id": "4866b179-bf7b-460e-8903-bda849861d88",
    "name": "User",
    "role": "user"
  },
  "locale": "en-US",
  "text": "hell0",
  "textFormat": "plain",
  "timestamp": "2019-06-10T15:05:40.760Z",
  "type": "message"
}

{
  "error": {
    "code": "ServiceError",
    "message": "response.text is not a function"
  }
}

我尝试过配置一个与仿真器说明的配置端点匹配的端点,但这只会导致无限连接消息,甚至不允许我向机器人输入任何文本。我还尝试过重新安装模拟器,但这并没有改变任何内容。

已编辑

此外,模拟器配置为绕过本地地址的ngrok,并且本地替代设置为localhost。这些是默认设置,并且切换旁路选项或更改本地替代不能解决问题。

我尝试从appsettings.json文件中获取AppId和AppPassword,方法是将它们注释掉并保留为空字符串,但这两个都不能解决问题。

我还卸载并重新安装了Visual Studio,BotFramework SDK,模板和Bot仿真器,以查看是否可以解决任何问题,但它们不能解决问题。

最后一点,我尝试遵循有关使用模拟器的Microsoft BotFramework教程,任何尝试都会产生此结果。

更新

重新安装Bot Framework Emulator v4.4.2之后,问题仍然存在,但是出现了新的错误消息:

[14:03:32]Emulator listening on http://localhost:61486
[14:03:32]ngrok not configured (only needed when connecting to remotely 
hosted bots)
[14:03:32]Connecting to bots hosted remotely
[14:03:32]Edit ngrok settings
[14:03:32]The bot's Microsoft App Id or Microsoft App Password is 
incorrect.
[14:03:32]POSTdirectline.conversationUpdate
[14:03:32]The bot's Microsoft App Id or Microsoft App Password is 
incorrect.
[14:03:32]POSTdirectline.conversationUpdate
[14:03:32]POST200directline.startConversation

我已确保它们确实匹配,但仍然出现此错误。

2 个答案:

答案 0 :(得分:0)

尝试从解决方案以及仿真器中删除应用程序ID,密码和ngrok,并在仿真器中仅添加localhost端点

答案 1 :(得分:0)

您是代理人吗?我有完全一样的问题。我在代理服务器后面。相同的代码在我的Mac上确实可以很好地工作。但是在工作的Windows PC上却没有。我不知道这是否有帮助!我认为该错误是通用的,但最重要的是,它无法从login.microsoftonline.com获取JWTToken。