0

我正在尝试使用 ngrok 和 nuget 包 Telegram.Bot.Core 测试我的 Telegram Bot... 这些是我目前正在执行的步骤:
1)我使用 Lampp 启动一个 Web 服务器(因为我使用的是 Arch Linux)
2)然后我使用以下命令启动 ngrok:ngrok http 8443
3)最后一步......我运行我的代码示例:

myBot.SetWebhookAsync("https://address.ngrok.io").Wait();

myBot.StartReceiving(Array.Empty<UpdateType>());
Console.WriteLine("Starting Receiving");
Console.ReadLine();
myBot.StopReceiving();

问题是 localhost:8443 无法访问,我不知道为什么。
我尝试在launch.json的配置属性中添加“debugServer”:8443,但localhost:8443仍然无法访问..我做错了什么?

4

1 回答 1

0

要使用 ngrok 共享您的本地主机和测试 Telegram Bot,您应该执行以下步骤:

- 步骤1

编辑位于中的 Visual Studio 应用程序配置文件../.vs/config/applicationhost.config(从项目根文件夹中跟随它)。

找到 bindings 标签并添加第二个 binding 标签(“localhost”刚刚删除):

<configuration>
...
    <sites>
    ...
        <site ...>
            <bindings>
                <binding protocol="http" bindingInformation="*:5000:localhost" />
                <binding protocol="http" bindingInformation="*:5000:" />
            </bindings>
        </site>
    ...
    </sites>
...
</configuration>

请注意,不要执行此步骤来绑定使用 8080 端口的标签。

- 第2步

以管理员身份运行 Visual Studio 并打开您的项目。

- 第 3 步

关闭防火墙。

- 第4步

运行 ngrok 并输入 " ngrok http 8443" 命令然后回车。

- 第 5 步

例如,打开您喜欢的浏览器之一并转到api.telegram.org/bot<Token>/setwebhook?url=<Domain>地址。

在此 URL 中是您的机器人令牌,并且是您使用 https 的 ngrok 转发地址。

(例如https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/setwebhook?url=https://01e08160.ngrok.io/api/Update:)

于 2018-08-13T21:19:33.967 回答