我正在尝试使用bot框架模拟器连接到我的BOT。这是错误的
异常:响应状态代码不表示成功:401(拒绝访问)。 [文件类型' text / plain']
当我查看错误消息的详细信息时,它将服务网址显示为http://localhost:31727
但我的机器人网址是http://localhost:3979/api/messages
你能帮我解决这个问题吗?
我在下面附上了完整的错误消息。
{
"输入":"消息",
" timestamp":" 2017-03-08T09:51:40.142Z",
" serviceUrl":" http://localhost:31727",
" channelId":"模拟器",
"来自":{
" id":" l0352n0fl2ja1ede6",
"姓名":" Bot"
},
"对话":{
" id":" 67infihmnjcl68bd7c"
},
"收件人":{
" id":"默认用户"
},
" locale":" en-US",
" text":"例外:响应状态代码不表示成功:401(拒绝访问)。",
"附件":[
{
" contentType":" text / plain",
&#34;内容&#34;:&#34; at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()\ r \ n at Microsoft.Bot.Builder.Luis.LuisService.d__3.MoveNext()\ r \ n --- ---从先前位置抛出异常的堆栈跟踪结束--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n,位于System.Runtime.CompilerServices的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n。 TaskAwaiter 1.GetResult()\r\n at Microsoft.Bot.Builder.Luis.Extensions.<QueryAsync>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()\ r \ n在Microsoft.Bot.Builder.Dialogs.LuisDialog 1.<MessageReceived>d__7.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n at Microsoft.Bot.Builder.Dialogs.Internals.DialogTask.ThunkResume
1.d__5.MoveNext()\ r \ n ---以前的堆栈跟踪结束抛出异常的位置--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n在系统中.Runtime.CompilerServices.TaskAwaiter 1.GetResult()\r\n at Microsoft.Bot.Builder.Internals.Fibers.Wait
2.-PollAsync&gt; d__19.MoveNext()\ r \ n ---从抛出异常的上一个位置开始的堆栈跟踪结束--- \ r \ n在System.Runtime 。 System.Runtime.CompilerServices.TaskAwaiter 1.GetResult()\r\n at Microsoft.Bot.Builder.Internals.Fibers.Frame
上的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n中的CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n 1.-PollAsync&gt; d__9 .MoveNext()\ r \ n ---从抛出异常的上一个位置开始的堆栈跟踪结束---在系统上的System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n中的\ r \ n。 System.Runtime.CompilerServices.TaskAwaiter 1.GetResult()\r\n at Microsoft.Bot.Builder.Internals.Fibers.Fiber
中的Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n 1.-PollAsync&gt; d__16.MoveNext()\ r \ n ---堆栈跟踪结束抛出异常的前一个位置--- \ r \ n在Microsoft.Bot.Builder.Internals.Fibers.Wait 2.Microsoft.Bot.Builder.Internals.Fibers.IAwaiter<T>.GetResult()\r\n at Microsoft.Bot.Builder.Dialogs.Chain.LoopDialog
1.d__3的System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\ r \ n中。 MoveNext()\ r \ n ---从抛出异常的上一个位置开始的堆栈跟踪结束--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n \ n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n,位于System.Runtime.CompilerServices.TaskAwaiter.GetResult()\ r \ n,位于Microsoft.Bot.Builder.Dialogs.Internals.DialogTask.ThunkResume 1.<Rest>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()\ r \ n在Microsoft.Bot.Builder.Internals.Fibers.Wait 2.<Microsoft-Bot-Builder-Internals-Fibers-IWait<C>-PollAsync>d__19.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()\ r \ n在Microsoft.Bot.Builder.Internals.Fibers .Frame 1.<Microsoft-Bot-Builder-Internals-Fibers-IFrameLoop<C>-PollAsync>d__9.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()\ r \ n在Microsoft.Bot.Builder.Internals.Fibers.Fiber 1.<Microsoft-Bot-Builder-Internals-Fibers-IFiberLoop<C>-PollAsync>d__16.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()\ r \ n在Microsoft.Bot.Builder.Dialogs .Internals.DialogTask.d__23.MoveNext()\ r \ n ---从抛出异常的上一个位置开始的堆栈跟踪结束--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n,位于System.Runtime.CompilerServices.TaskAwaiter.GetResult()\ r \ n,位于Microsoft.Bot.Builder.Dialogs.Internals.ReactiveDialogTask。 d__3.MoveNext()\ r \ n ---来自pre的堆栈跟踪结束抛出异常的vious位置--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n at System.Runtime.CompilerServices.TaskAwaiter.GetResult()\ r \ n在Microsoft.Bot.Builder.Dialogs.Internals.ScoringEventLoop`1.d__5.MoveNext()\ r \ n ---从上一个位置开始的堆栈跟踪异常被抛出--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n在System.Runtime .CompilerServices.TaskAwaiter.GetResult()\ r \ n在Microsoft.Bot.Builder.Dialogs.Internals.PersistentDialogTask.d__4.MoveNext()\ r \ n ---从先前位置抛出异常的堆栈跟踪结束 - - \ r \ n在Microsoft.Bot.Builder.Dialogs.Internals的System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\ r \ n中.PersistentDialogTask.d__4.MoveNext()\ r \ n ---从抛出异常的上一个位置开始的堆栈跟踪结束--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n位于System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n,位于System.Runtime.CompilerServices.TaskAwaiter.GetResult()\ r \ n,位于Microsoft.Bot.Builder.Dialogs.Internals.ExceptionTranslationDialogTask.d__2。 MoveNext()\ r \ n ---从抛出异常的上一个位置开始的堆栈跟踪结束---在System.Runtime上的System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n中的\ r \ n \ n \ n System.Runtime.CompilerServices.TaskAwaiter.GetResult()\ r \ n的.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n在Microsoft.Bot.Builder.Dialogs.Internals.SerializeByConversation.d__4.MoveNext()\ r \ n \ n ---从抛出异常的上一个位置开始的堆栈跟踪结束--- \ r \ n在System.Runtime.CompilerS在Microsoft的System.Runtime.CompilerServices.TaskAwaiter.GetResult()\ r \ n的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n中的ervices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n。 Bot.Builder.Dialogs.Internals.SetAmbientThreadCulture.d__2.MoveNext()\ r \ n ---从抛出异常的先前位置开始的堆栈跟踪结束--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (任务任务)\ r \ n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n,位于System.Runtime.CompilerServices.TaskAwaiter.GetResult()\ r \ n,位于Microsoft.Bot.Builder.Dialogs .Internals.PostUnhandledExceptionToUser.d__5.MoveNext()&#34;
}
]
&#34;实体&#34;:[],
&#34; replyToId&#34;:&#34; fc5lb3ii344hk7hnac&#34;,
&#34; id&#34;:&#34; jmi06madf5020naii&#34;,
&#34; localTimestamp&#34;:&#34; 2017-03-08T15:21:40 + 05:30&#34;
}
登录
答案 0 :(得分:0)
我猜你的机器人配置没问题。很可能,问题是由Microsoft.Bot.Builder.Luis.LuisService(在附加堆栈上)引起的,您没有提供正确的凭据,这就是您获得401的原因。
尝试实现一个更简单的bot(hello word)来验证你与模拟器的连接是否正常。
PS。您可以运行Fiddler查看所有请求,并查看哪个请求实际上已失败。
答案 1 :(得分:0)
您是否尝试将AppId和AppSecret放入模拟器中?您可以在项目的Web.config
文件中找到这些值。
<appSettings>
<add key="MicrosoftAppId" value="YourAppId" />
<add key="MicrosoftAppPassword" value="YourAppPassword" />
</appSettings>
答案 2 :(得分:0)
I was facing similar issue and fixed by adding below appSettings in config file:
<add key="LuisAppId" value="2342342323423423424"/>
<add key="LuisAPIKey" value="2342343453423423423"/>
<add key="LuisAPIHostName" value="westeurope.api.cognitive.microsoft.com"/>
PS: Make sure to add above settings specific to your application :>