是什么导致 500 Internal Server Error due to localhost:9000 being in bot framework?

What's causing 500 Internal Server Error due to localhost:9000 being hit in bot framework?

每次我尝试向我的 bot 发送消息时,或者在它连续响应 3 条消息后出现此错误。

我在出现异常的代码周围放置了一个 try/catch(来自对 context.PostAsync 的调用)并将其记录在我的 Application Insights 实例中:

An error occurred while sending the request.
Unable to connect to the remote server
An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:9000

当然 my 代码中没有任何内容命中 localhost...还有其他人看到了吗?

发生错误时 运行ning 的代码:

var j = JToken.Parse(responseJson);
foreach (var b in j["value"])
{
    await context.PostAsync($"{b.Value<string>("id")} - {b.Value<string>("name")}");
}

当我在本地 运行 机器人并使用 Emulator 进行测试时,我得到了 3 个项目输出,但在第 4 个输出了 500 个(这不是畸形的 json 分辨率是失败)。

当我发布到 Azure 应用服务时,出现 500 错误,没有任何输出。

您是否通过模拟器连接到已部署的服务?

如果是这样,可能会产生此错误,因为当我们看到来自 channelId="emulator" 的消息时,异步消息被路由到 http://localhost:9000。这将导致使用此端口。

要对其部署进行测试,您应该从机器人配置页面上的测试 window 开始,或者使用网络聊天控件。

我们在我们的应用程序中遇到了类似的问题。通过在我们的对话框 class 中没有派生自 LuisDialog 的私有 LuisResult 属性 设法解决了 500 个无效响应。

我猜因为 class 被标记为 Serializable 它试图序列化所有属性,而 LuisResult 无法序列化。

这是一个代码片段:

变化:

[Serializable]
public class YourDialog : LuisDialog<MySerializableClass>
{
    private LuisResult _myPrivateProp;
}

收件人:

[Serializable]
public class YourDialog : LuisDialog<MySerializableClass>
{
    private string _myPrivateProp;//or whatever
}

我也遇到了“500 内部服务器错误” 更新到最新 "Bot Framework Emulator" 解决了我的问题。

Link to Bot Framework Emulator :

Documentation:

希望对您有所帮助。