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

故事扮演 提交于 2019-12-31 02:23:07

问题


Getting this error every time I try to send a message to my bot, or after it responds with 3 messages in a row.

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

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")}");
}

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).

When I publish out to Azure App Services, I get 500 error without any output.


回答1:


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.

I guess as the class was marked as Serializable it tried to serialize all the properties and a LuisResult can't be serialized.

Here's a code snippet:

Change:

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

To:

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



回答2:


Did you connect to your deployed service via the emulator?

If so that could generate this error, because when we see a message from channelId="emulator" async messages are routed to http://localhost:9000. That would cause this port to be used.

To test it deployed you should start with the Test window on the bot configuration page, or use the web chat control.




回答3:


I was also facing the “500 internal server error” updating to the latest "Bot Framework Emulator" solved my issue.

Link to Bot Framework Emulator :

Documentation:

Hope this helps.



来源:https://stackoverflow.com/questions/36583343/whats-causing-500-internal-server-error-due-to-localhost9000-being-hit-in-bot

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!