是什么导致500内部服务器错误,原因是在bot框架中命中了localhost:9000? [英] What's causing 500 Internal Server Error due to localhost:9000 being hit in bot framework?
问题描述
每次我尝试向机器人发送消息时,或者在它连续响应3条消息后,都会出现此错误.
Getting this error every time I try to send a message to my bot, or after it responds with 3 messages in a row.
我在正在获取异常(从对context.PostAsync
的调用)的代码中放置try/catch
,并将其记录在我的Application Insights实例中:
I put a try/catch
around the code that's getting the exception (from a call to context.PostAsync
) and got this logged in my Application Insights instance:
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
肯定地,我代码中没有任何内容击中localhost
...其他人看到了吗?
Certainly nothing in my code is hitting localhost
... anybody else seeing this?
发生错误时正在运行的代码:
Code that's running when the error occurs:
var j = JToken.Parse(responseJson);
foreach (var b in j["value"])
{
await context.PostAsync($"{b.Value<string>("id")} - {b.Value<string>("name")}");
}
当我在本地运行该bot并使用仿真器进行测试时,我得到3项输出,但在第4项中输出了500(这不是格式错误的,以致于json解析失败).
When I run the bot locally and use the Emulator to test I get 3 items output but 500 on the 4th (which isn't malformed in a way such that the json resolution is failing).
发布到Azure App Services时,出现500错误,没有任何输出.
When I publish out to Azure App Services, I get 500 error without any output.
推荐答案
我们的应用程序中存在类似的问题.通过在我们的对话框类中没有从LuisDialog
派生的私有LuisResult
属性来设法解决500个无效响应.
We were having a similar issue in our app. Managed to resolve the 500 Invalid responses by not having a private LuisResult
property in our dialog class that derived from LuisDialog
.
我猜是因为该类被标记为Serializable
,所以它试图序列化所有属性,而LuisResult
无法序列化.
I guess as the class was marked as Serializable
it tried to serialize all the properties and a LuisResult
can't be serialized.
这是一个代码段:
更改:
[Serializable]
public class YourDialog : LuisDialog<MySerializableClass>
{
private LuisResult _myPrivateProp;
}
收件人:
[Serializable]
public class YourDialog : LuisDialog<MySerializableClass>
{
private string _myPrivateProp;//or whatever
}
这篇关于是什么导致500内部服务器错误,原因是在bot框架中命中了localhost:9000?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!