0

我在过去几周开始工作(或尝试)Simple MVC-App 以获取通知。

我使用了这个示例并使用 ngrok 建立了 iP-tunnels ot localhost。(请参阅下面的示例和内容页面)。 https://docs.microsoft.com/de-de/learn/modules/msgraph-changenotifications-trackchanges/5-exercise-change-notification

https://github.com/microsoftgraph/msgraph-training-changenotifications/tree/live

如果我同时只在本地应用程序上运行一切都很好,但如果我将启动第二个通知应用程序,它会失败并显示此消息

System.IO.IOException: Failed to bind to address https://127.0.0.1:5001: address already in use. ---> Microsoft.AspNetCore.Connections.AddressInUseException: Normalerweise darf jede Socketadresse (Protokoll, Netzwerkadresse oder Anschluss) nur jeweils einmal verwendet werden.

我在 ngrok.yml 文件中尝试了一些更改,但也无法访问。

# Create 3 tunnels, each for different ports, with only https enabled
# This way the ngrok process stays bellow the Free plan limit (4 tunnels)

authtoken: **************************
log: ngrok.log
tunnels:
  first:
    addr: 5000
    proto: http
    #host_header: localhost
  second:
    addr: 5000
    proto: http
    #host_header: localhost

我试图更改 appsetting.json 中的 url,但它不起作用:

{
    "Logging": {
      "LogLevel": {
        "Default": "Debug"
      }
    },
    "AllowedHosts":"*",
    "MyConfig": {
    "AppId": "****************",
    "AppSecret": "*********************",
    "TenantId": "********",
    "Ngrok": "https://76bd76a6aca4.ngrok.io"
  }
}

但是在启动第一个应用程序后,第二个应用程序因异常而崩溃。然后我尝试使用端口 5000 m 5010 等等,并更改了 launchsetting.json 中的设置,但我又失败了。

"msgraphapp": {
  "commandName": "Project",
  "launchBrowser": true,
  "launchUrl": "api/values",
  "applicationUrl": "https://localhost:5001;http://localhost:5000",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"

请有人告诉我我必须做什么,以便我可以启动 2 个或更多在 localhost 上运行的应用程序,并使用 ngrok 或替代方案进行隧道传输。

4

1 回答 1

0

您必须遵循练习 - Azure AD 应用程序 .NET 核心 Web API。让两个应用程序运行并公开两个 Ngrok 隧道以获取图形更改通知

首先配置你的~/.ngrok2/ngrok.yml如下所示。注意不同的端口。

authtoken: ****...***
tunnels:
  first:
    addr: 5000
    proto: http
  second:
    addr: 5010
    proto: http%

其次编辑您的每个应用程序属性以具有不同的 http 和 https 绑定端口集。请参阅下面的屏幕截图,其中显示了每个文件的 launchSettings.json 设置。

这样,您应该能够运行两个 .net 应用程序,每个应用程序都具有用于 MS 图形的 Ngrok 隧道。

请记住将正确的 Ngrok url 添加到每个 appSettings

在此处输入图像描述

于 2021-08-25T11:19:28.077 回答