Botframework模拟器和404错误

时间:2016-06-08 10:49:26

标签: botframework

我正在尝试编写一个使用LUIS的简单机器人,但似乎在更新后出现问题。

因此,在将Botbuilder更新为1.1之前,我遇到了无法找到Luis.Models的问题。升级后,解析coding error,并删除Microsoft.Bot.Connector.Utilities,我可以编译并成功运行,但我无法通过模拟器连接。

这是我正在使用的代码。

using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Description;
using System.Collections.Generic;
using Microsoft.Bot.Connector;
using Microsoft.Bot.Builder.Dialogs;
//using Microsoft.Bot.Connector.Utilities;
using Microsoft.Bot.Builder.Luis;
using Microsoft.Bot.Builder.Luis.Models;
using Newtonsoft.Json;

[LuisModel("c413b2ef-382c-45bd-8ff0-f76d60e2a821", "6d0966209c6e4f6b835ce34492f3e6d9")]
[Serializable]
public class Mybot : LuisDialog<object>
{

    [LuisIntent("")]
    public async Task None(IDialogContext context, LuisResult result)
    {
        string message = "I'm sorry I didn't understand. Try asking about your bill.";
        await context.PostAsync(message);
        context.Wait(MessageReceived);
    }

    [LuisIntent("NextInvoiceDate")]
    public async Task NextInvoiceDate(IDialogContext context, LuisResult result)
    {
        string message = "Your next payment will go out on the 17th of the month.";
        await context.PostAsync(message);
        context.Wait(MessageReceived);
    }

    [LuisIntent("NextAmount")]
    public async Task NextAmount(IDialogContext context, LuisResult result)
    {
        string message = $"Your next amount is expected to be around £29.72.";
        await context.PostAsync(message);
        context.Wait(MessageReceived);
    }
}

当我运行项目时,它启动没有错误,我得到的网页上写着:

MYBot 在这里描述您的机器人和您的使用条款等。 访问Bot Framework注册您的机器人。注册时,请记住将机器人的端点设置为 https://your_bots_hostname/api/messages

当我运行指向https://localhost/api/messages的模拟器时,它会返回“发送请求时发生错误”。

JSON在这里:

System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:443
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
   at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Microsoft.Bot.Connector.Emulator.ConversationModel.<SendMessageAsync>d__50.MoveNext() 

我也尝试过HTTP(而不是HTTPS)。

3 个答案:

答案 0 :(得分:1)

你能检查一下你的机器人使用的是正确的网址吗?检查项目属性中的项目URL,并确保使用正确的端口号。默认情况下,Bot Framework项目模板使用http://localhost 3978 /

Project Properties

答案 1 :(得分:1)

我在这里看到的两件事:

  1. 您正在使用https和localhost,并且应该是http(https是在Azure中托管的时候)
  2. 该港口正在招架
  3. 此外,即使您使用LUIS(这基于您添加的评论),您仍然需要MessageController。

    MessageController将接收消息并通过&#34;启动&#34;开始对话。对话。在这种情况下,您的LUIS对话框。

答案 2 :(得分:0)

我认为在模拟器端点中您错过了端口号。通常它是http(localhost),但是为模拟器URL添加's'为'https',如下所示。 https://localhost:3978/api/messages