【问题标题】:Is there an issue with Bot Framework Virtual Assistant template when Direct Line App Service Extension is enabled启用 Direct Line App Service Extension 时,Bot Framework 虚拟助手模板是否存在问题
【发布时间】:2022-01-23 23:35:43
【问题描述】:

我已经使用虚拟助手模板部署了 Azure Bot,在我启用 Direct Line App Service Extension 之前,它运行良好(并且仍在使用 Portal 的 Test In Web Chat 功能)。

启用 DL 应用服务扩展的主要目标是隔离机器人访问和保护应用服务。

我已遵循 MS 文档 https://docs.microsoft.com/en-us/azure/bot-service/bot-service-channel-directline-extension-net-bot?view=azure-bot-service-4.0 并确保每个步骤都配置正确。

确保 DL 应用服务正常工作的主要步骤是检查 https://xxx.azurewebsites.net/api/messageshttps://xxx.azurewebsites.net/.bot/ url 是否返回正确的 json 结果 f.x: {"v":"123","k":true, "ib":true,"ob":true,"initialized":true} 但相反,我收到错误响应 400 错误请求,并且浏览器中出现错误消息:“需要升级到 WebSocket。”

我什至无法达到此处提到的故障排除指南:https://docs.microsoft.com/en-us/azure/bot-service/bot-service-channel-directline-extension-net-bot?view=azure-bot-service-4.0#troubleshooting 可以帮助解决的步骤。

正如我之前所说,Bot 仍在工作,并且 url:https://xxx.azurewebsites.net 正确加载站点,可以在下面看到

感谢任何帮助

【问题讨论】:

  • 我自己尝试过,并且能够达到故障排除指南中的步骤。您确定没有错过Still within the Configuration section, select the General settings section and turn on Web sockets. 的步骤吗?
  • 您好@AP01,是的,我已从常规设置部分启用 WebSocket 选项,我感觉在调用应用程序服务时某处发生超时,因为在客户端页面上我收到 Web 套接字连接失败错误(但即使 Always On 选项也设置为 ON),为了详细说明,我已在 github 上向 botframework-solution 团队报告了问题:github.com/microsoft/botframework-solutions/issues/3849
  • 关于 ANCM 混合主机的故障排除页面上有进一步的步骤。在我启用它之前,我无法得到回应。这对你有影响吗?
  • 你好@AP01,如果 ANCM 混合主机意味着配置 OutOfProcess,是的,我已经在 csproj 文件中配置了这个。 OutOfProcess 有什么方法可以深入检查导致问题的原因吗?
  • 您可以在 IDE 中打开机器人并单步调试调试器以查看是否弹出任何错误。对于 C# 机器人,我建议使用 Visual Studio,或者 VSCode。

标签: botframework azure-bot-service


【解决方案1】:

这些是我所做的更改并且有效:

参考回购与示例代码: https://github.com/SSanjeevi/VirtualAssistantDirectlineExtn

Wrote detailed here.

项目文件:

 <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<NoWarn>NU1701</NoWarn>
<Version>1.0.3</Version>

BotController.cs

 private readonly IBotFrameworkHttpAdapter adapter;

 public BotController(IBotFrameworkHttpAdapter httpAdapter, IBot bot)

Startup.cs

配置服务方法:

 // Register the Bot Framework Adapter with error handling enabled.
            // Note: some classes use the base BotAdapter so we add an extra registration that pulls the same instance.
            services.AddSingleton<IBotFrameworkHttpAdapter, DefaultAdapter>();
            services.AddSingleton<BotAdapter>(sp => sp.GetService<BotFrameworkHttpAdapter>());
            // Configure channel provider

配置方法:

使用 Microsoft.Bot.Builder.Integration.AspNet.Core; app.UseHsts();

            app.UseCors(x => x.AllowAnyOrigin()
                .AllowAnyHeader()
                .AllowAnyMethod());
            // Allow the bot to use named pipes.
            app.UseNamedPipes(System.Environment.GetEnvironmentVariable("APPSETTING_WEBSITE_SITE_NAME") + ".directline");

网络聊天:

   let directLineConnection = await window.WebChat.createDirectLineAppServiceExtension({
                domain: domainUrl,
                token
            });

附加的repo code 还包含 serilog 实现,以便在应用服务中登录日志流,如果您遇到任何问题,您可以在其中查看错误日志。

按照这篇文章,在 bot api 中实现 serilog 并部署。 https://lkgforit.com/troubleshooting-by-writing-logs-at-the-application-start-for-net-core-app-using-serilog-14a1914701af

【讨论】:

  • 您好@Sanjeevi,感谢您的评论,这些是我遵循的确切步骤,即使我会说您的 PR 帮助我了解了整个过程,不幸的是问题仍然存在(即使在完成所有这些更改,实际上我在您的 github 问题中发表了评论),请您在这里查看我的线程:github.com/MicrosoftDocs/bot-docs/issues/…,问题是当我使用自己的应用服务 url 生成令牌时生成令牌:xxx.azurewebsites.net/.bot/v3/directline/tokens/generate,请参阅给定线程你会理解我的担忧。
  • 当我使用 directline.botframework.com/v3/directline/tokens/generate 作为颁发者时,我得到了令牌,但是如果我使用它,我得到 web socket failed 错误,因为(我理解)这是公共端点和从这个域生成的令牌不适用于启用了 DL ASE 的我的应用服务
  • 尝试在网络聊天中的直接连接中不提及您的域并尝试。我不记得确切,但是在遇到像您这样的问题并且它奏效后,我做了一些寻求,这是一小步。是否在应用配置中添加了直达扩展keyin?
  • 按照这篇文章,在bot api中实现serilog并部署。 lkgforit.com/…。之后,在从浏览器访问 .bot url 和从前端网络聊天时检查应用服务中的日志流。您会在控制台中遇到一些错误。
  • @PravinAmbekar。 - 请参阅此 repo 中的示例代码:github.com/SSanjeevi/VirtualAssistantDirectlineExtn 它适用于我的全新应用服务和机器人。
猜你喜欢
  • 2022-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多